Extending Django settings.py File
When first learning Django & python, one issue I had was how to store my settings.py file in SVN. It’s been a while and things are a little hazy, but I remember my settings.py file in my local development environment was always out of sync and I was careful not to include it in updates.
I’ve since learned a better way that is actually quite common as I have seen. I am also now using git… but that’s neither here nor there.
In my opinion, your settings.py file should only contain what should be on your live site. This should be in your repository. You can then extend your settings by adding the following at the bottom of your settings.py file:
try:
from local_settings import *
except ImportError:
pass
Now you can add a local_settings.py file in the same directory as your settings.py file. Simply override the settings you want such as “DEBUG = True”
Don’t add your local_settings.py file to the repository. Ideally, your live server should not have a local_settings.py file.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
May 13, 2010
·
Dustin ·
14 Comments
Tags: django · Posted in: Programming & Internet
-
Dmitry
-
Florent V.
-
http://mikewatkins.ca/tags/python/ Michael Watkins
-
Harro
-
http://tirl.org Charlie
-
http://www.catalystic.com Mark
-
http://esauro.wordpress.com esauro
-
Warren
-
Florent V.
-
Anonymous
-
http://sickboy.ru Sickboy
-
http://homytivi.blogspot.com/ HomeTivi


