Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

23 Settings and debug toolbar

scotwk edited this page May 12, 2015 · 1 revision

Logout on browser close

Currently users can log themselves out using the link in the top right. If you want to automatically have users logged out when they close their browser you can add this line to the elevennote/settings.py file:

SESSION_EXPIRE_AT_BROWSER_CLOSE = True

More settings

Since the settings file is written in Python you can write Python code to access settings.

Also, the settings file can be imported and accessed from views (or other code) to conditionalize based on settings:

from django.conf import settings

if settings.DEBUG:
    # Do something

More documentation on settings: https://docs.djangoproject.com/en/1.8/topics/settings/

List of all settings: https://docs.djangoproject.com/en/1.8/ref/settings/

Django Debug Toolbar

The Django debug toolbar is an add-on that runs in the browser when the server's Debug=True setting is on. (Note: never run with Debug=True on production!)

$ pip install django-debug-toolbar

In elevennote/settings.py add this line into the INSTALLED_APPS.

'debug_toolbar',

If the server is running in debug mode the browser will include a useful sidebar that includes information such as

  • Request headers
  • All DB queries
  • Timing information
  • What template and view are being used
  • And much more