3 ms·
a lot more information here https://code.djangoproject.com/wiki/SplitSettings https://code.djangoproject.com/wiki/SplitSettings I typically use this set up: -
by DanielN 15y ago
a lot more information here https://code.djangoproject.com/wiki/SplitSettings https://code.djangoproject.com/wiki/SplitSettings
I typically use this set up:
- settings.py contains global settings that aren't effected by deployment level.
- at the bottom of that file you have
try:
from settings_local import *
except:
pass
- in settings_local.py you have your deployment level dependent settings
- then just git ignore settings_local.py
- tvon 15y agoI think you're missing an 's' there: https://code.djangoproject.com/wiki/SplitSettings https://code.djangoproject.com/wiki/SplitSettings
- DanielN 15y agoopps, fixed. Thanks
- ceol 15y agoThat's an except ImportError: right? ;)
- shill 15y agoI've tried a few different strategies and found this method works best for me. In my fabfile I have environment 'setters' that precede regular commands. So I can do 'fab qa deploy' or 'fab prod deploy' and the deploy command grabs the correct settings_local file for the target environment.
- yuvadam 15y agoEven better than gitignoring your local_settings - Save your local settings as settings_local.py.exmp and then ln -s settings_local.py.exmp settings_local.py Giving you working local settings, and a versioned copy of them, that is useless unless linked properly.