You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project is an awesome starter template. Thanks!
Problem
Maybe it would be a good idea to add some kind of library to handle your environment to activate different settings? Some popular examples: django-configurations and django-split-settings.
Solution
Here's a brief example, how to use django-split-settings. We will need new settings package structure:
"""This is a django-split-settings main file.For more information read this:https://github.com/sobolevn/django-split-settingsDefault environment is `development`. To run app:`python manage.py runserver`To change the settings file:`DJANGO_ENV=testing python manage.py runserver`"""fromosimportenvironfromsplit_settings.toolsimportoptional, includeENV=environ.get('DJANGO_ENV') or'development'base_settings= [
'components/common.py', # standard django settings'components/database.py', # database setup'components/email.py', # smtp# and any other components you need# 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 template. Thanks!
Problem
Maybe it would be a good idea to add some kind of library to handle your environment to activate different settings? 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?
The text was updated successfully, but these errors were encountered: