Appendix D. Settings

Your Django settings file contains all the configuration of your Django installation. This appendix explains how settings work and which settings are available.

The Basics of Settings Files

A settings file is just a Python module with module-level variables.

Here are a couple of example settings:

DEBUG = False
TEMPLATE_DIRS = ('/home/templates/mike', '/home/templates/john')

Because a settings file is a Python module, the following apply to it:

  • It must be valid Python code; syntax errors aren't allowed.

  • It can assign settings dynamically using normal Python syntax, for example

    MY_SETTING = [str(i) for i in range(30)]
  • It can import values from other settings files.

Default Settings

A Django ...

Get The Definitive Guide to Django: Web Development Done Right, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.