How to manage local vs production settings in Python Django?

To manage local vs production settings in Python Django, we can create separate settings files for each environment.

For instance, in settings/local.py, we add the dev environment settings like:

from project.settings.base import *

DEBUG = True
INSTALLED_APPS += (
    'debug_toolbar', # and other apps for local development
)

And we create a settings/production.py file with the production environment settings like

from project.settings.base import *

DEBUG = False
INSTALLED_APPS += (
    # other apps for production site
)

Then we run our app with the settings file we want by running

./manage.py runserver 0:8000 --settings=project.settings.local

to run our app with the settings/local.py file.

And we run

 ./manage.py shell --settings=project.settings.production

to run our app with the settings/production.py file.