So far in this book, we've dealt with only a single settings file: the settings.py
generated by django-admin startproject
. But as you get ready to deploy, you'll likely find yourself needing multiple settings files to keep your development environment isolated from your production environment. (For example, you probably won't want to change DEBUG
from False
to True
whenever you want to test code changes on your local machine.) Django makes this very easy by allowing you to use multiple settings files. If you'd like to organize your settings files into production and development settings, you can accomplish this in one of three ways:
Set up two full-blown, independent settings files.
Set up a base settings file (say, for development) and a second (say, production) settings file that merely imports from the first one and defines whatever overrides it needs to define.
Use only a single settings file that has Python logic to change the settings based on context...