Settings¶
common.py¶
This file contains settings which are shared between development- and production-settings. The provide sane defaults for developing and a solid base for production settings.
Path Configuration¶
DJANGO_ROOT
- Absolute path of the projects Django directory
PROJECT_ROOT
- Absolute path of the project directory
SITE_NAME
- The name of our project
STATIC_ROOT
- The directory to collect static files into. It will be set to
[project_root]/run/static
. Please refer to the official settings documentation on STATIC_ROOT and this howto on static files. MEDIA_ROOT
- The directory for user-uploaded files. It will be set to
[project_root]/run/media
. Please refer to the official settings documentation on MEDIA_ROOT. STATICFILES_DIRS
- Django will look in these locations for additional static
assets to collect. Our settings module adds
[project_root]/static
to the list. See the official settings documentation on STATICFILES_DIRS for more details. PROJECT_TEMPLATES
Django will look in these locations for additional templates. Our settings module adds
[project_root]/templates
.This setting was changed to reflect the changes in Django 1.8: Django features the possibility to use multiple different template engines. This is controlled with the TEMPLATES directive and represents the old TEMPLATE_DIRS directive. See the official settings documentation on TEMPLATE_DIRS for more details.
Application Configuration¶
DEFAULT_APPS
- These are the default apps of
django-admin startproject
. Please note that this is no official setting. Django operates withINSTALLED_APPS
, which will be set in dev.py. MIDDLEWARE
- (new in 1.2; Django 1.10)
These are the default middleware classes, directly taken from the default
settings created by
django-admin startproject
. See the official settings documentation on MIDDLEWARE_CLASSES for more details. (Please note: This was used to be called MIDDLEWARE_CLASSES) TEMPLATES
- This setting reflects the new feature of multiple template engines, which was introduced in Django 1.8. The value is taken from the official upgrading guide and adjusted to include our project templates, defined in PROJECT_TEMPLATES.
Security Configuration¶
SECRET_FILE
- Django uses a
SECRET_KEY
for security purposes. As you can clearly see, this is a very sensitive information. We will store this key in a file. This file’s location is set up here. Default value is[project_root]/run/SECRET.key
. ADMINS
- You will have to fill this setting yourself, please refer to official settings documentation on ADMINS.
MANAGERS
- You will have to fill this setting yourself, please refer to official settings documentation on MANAGERS.
Django Running Configuration¶
WSGI_APPLICATION
- This setting determines the path to the WSGI-application. We’ll use the
default one, so this setting is set to
[project_name].wsgi.application
. ROOT_URLCONF
- Determines the root URLconf. Set to
[project_name].urls
. See official settings documentation on ROOT_URLCONF. SITE_ID
- (removed in 1.2) A unique ID of the site. See official settings documentation on SITE_ID.
STATIC_URL
- Determines, under which URL static files are served. You will want to
adjust this in a production scenario. Our default value is
/static/
. See official settings documentation on STATIC_URL. MEDIA_URL
- Determines, under which URL media files are served. You will want to
adjust this in a production scenario. Our default value is
/media/
. See official settings documentation on MEDIA_URL.
Debug Configuration¶
DEBUG
- Activates debugging. In this file, this is set to
False
, because these are our common settings, which are shared between all configurations. We just want debugging while we are developing, so debugging will be activated in dev.py. See official settings documentation on DEBUG for additional information.
Internationalization¶
LANGUAGE_CODE
- Sets the language of this project. See official settings documentation on LANGUAGE_CODE.
TIME_ZONE
- Sets the time zone of this project. See official settings documentation on TIME_ZONE.
USE_I18N
- Activates Django’s translation system. See official settings documentation on USE_I18N.
USE_L10N
- Activates Django’s localization engine. See official settings documentation on USE_L10N.
USE_TZ
- Make datetimes timezone aware. See official settings documentation on USE_TZ.
development.py¶
(modified in 1.2: renamed dev.py
to development.py
)
This file contains development settings. Plase note, that manage.py
will
now automatically use this setting-file as its default, while wsgi.py
still refers to production.py
.
Debug Configuration¶
DEBUG
- We are developing, so activate debugging.
ALLOWED_HOSTS
- (new in 1.2) Allow all hostnames to be used to access the server/project.
Database Configuration¶
DATABASES
- I use SQLite for development. The database file will be created in
[project_root]/run/dev.sqlite3
.
Application Configuration¶
INSTALLED_APPS
- We have set the default apps. Now we build the (required)
INSTALLED_APPS
-setting by usingDEFAULT_APPS
and add any app we need for development.
production.py¶
(modified in 1.2)
This file should contain production settings. Currently, it just reverts some
development specific configuration values, DEBUG
and ALLOWED_HOSTS
.
Please note, that the behaviour of manage.py
changed: It now uses the
settings in development.py
automatically, while [project_root]/wsgi.py
refers to the settings in production.py
.
djangodefault.py¶
(removed in 1.2)
This are the saved settings from django-admin startproject
. We just keep
them for completeness, these settings are not actually used.