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
DEFAULT_FROM_EMAIL = 'webmaster@example.com'
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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.