4 ms·
Don't do this. Keep everything in settings.py and use environment variables (django-environ) to configure it. In a project with tens and tens of apps and so m
by Alir3z4 5y ago
Don't do this.
Keep everything in settings.py and use environment variables (django-environ) to configure it.
In a project with tens and tens of apps and so many modules requiring configurations and easily reaching more than thousand settings key, keeping 1 settings.py has not failed me.
With the approach mentioned in the article, you'll get to a point where you'll be having so different setting module for each env.
01. local
02. testing
03. CI/CI
04. E2E
05. Docker
06. Kubernetes
07. staging
08. release
09. production
10. k8s_win.py
11. k8s_linux.py
12. k8s_mac.py
13. heroku.py
14. pie.py
15. home.py
16. vacation.py
17. ...
Soon you'll get to a place where you need to kind of merge 2 of them (settings/docker.py and settings/kubernetes.py) or worse, several of them and then hell is unleashed. You get confused, your team gets confused, the new team member is confused, no one has any idea where to look at.
Just keep it in 1 place, let your brain stay healthier and prevent early cancer.
- senko 5y agoOP here. I agree with you. Quoting from the article: > We can now go back to only having settings.py that imports dotenv, fetches the configuration, and initializes Django settings as needed.
- jmath 5y agoanything to prevent early cancer
- marcosdumay 5y agoWell, now you have the exactly equivalent problem of managing your environment variables. What is better depends on your tooling.
- mattupstate 5y agoI'd go so far as to say that configuration details for specific runtime environments should never be the concern of the application/service/program itself. It's almost always a smell to me when I see "dev" "prod" "stage" "local" in code unless it's an abstraction over the configuration for some sort of logical runtime profile.
- scwoodal 5y agoCan you share an example of what a single settings file looks like that configures the 1 through 17 environments you have listed?