"""
This is a django-split-settings main file.
For more information read this:
https://github.com/sobolevn/django-split-settings
Default environment is `production`.
To change settings file:
`DJANGO_ENV=testing python manage.py runserver`
"""
from os import environ
from split_settings.tools import optional, include
ENV = environ.get('DJANGO_ENV') or 'production' # since it's a production-ready template
base_settings = [
'components/common.py', # standard django settings
'components/database.py', # database setup
# Select the right env:
'environments/%s.py' % ENV,
# Optionally override some settings:
optional('environments/local.py'),
]
# Include settings:
include(*base_settings)
So after that it would be crystal-clear for users where to put extra configurations like: django-debug-toolbar and other which are used for development or testing only.
Conclusion
Pros:
Clear settings structure
No refactoring and no effect on the end user
Multiple possible environments with reasonable default
Cons:
Extra dependency
Maybe I am missing any cons, please correct me if I am wrong.
This project is an awesome starter for the
heroku
-based apps. Thanks!Problem
But one thing caught my eye: there's only one configuration file for all possible envs:
development
,stage
,testing
,production
andlocal
.Maybe it would be a good idea to add some kind of library to handle that? Some popular examples:
django-configurations
anddjango-split-settings
.Solution
Here's a brief example, how to use
django-split-settings
. We will need newsettings
package structure:And here's
settings/__init__.py
:So after that it would be crystal-clear for users where to put extra configurations like:
django-debug-toolbar
and other which are used for development or testing only.Conclusion
Pros:
Cons:
Maybe I am missing any cons, please correct me if I am wrong.
Further readings
Here's a detailed article I wrote on this topic: https://medium.com/wemake-services/managing-djangos-settings-e2b7f496120d
So, what do you think?