3 ms·
Seems complicated. I always use four simple files: settings.py settings_development.py settings_staging.py settings_production.py Where the first one
by kennu 15y ago
Seems complicated. I always use four simple files:
settings.py
settings_development.py
settings_staging.py
settings_production.py
Where the first one has the defaults (usable for local development), and the others contain any overrides needed to run with Gunicorn on the corresponding dev/staging/production servers.
- nulluk 15y agoWe have a very similar approach except we encapsulate settings into its own package just for readability/maintainability. So it looks something like the following settings/ __init__.py defaults.py dev.py live.py testing.py users/ __init__.py *user specific settings*
- kennu 15y agoI wonder what kind of maintainability benefits do the separate packages bring in this case? To me, having a lot of empty __init__.py files and subdirs reduces readability, so I like to maximize simplicity.
- wesleyzhao 15y agoI do something very similar. But I just have dummy files in folder depending on the environment (so I do something like 'touch PRODUCTION' or 'touch STAGING') and based off which file is present I know which settings to serve. Here's a good example (start at line 207): https://github.com/armon/DjangoProjectExample/blob/master/project/settings.py https://github.com/armon/DjangoProjectExample/blob/master/pr...