I have a several environments for my project. DEV
for development, BETA
for beta testing, PRODUCTION
for production deployment. Each of these environments share lot of settings, but have different databases.
I was wondering if there is any elegant solution to maintain settings.py
for different environments without duplicating them in another settings.py
file (e.g. using inheritance)
Thanks for your replies.
Setting files are just python modules. Often, the following structure is used:
settings/
|-- base.py
|-- production.py
|-- development.py
Then, in your environment-specific settings, at the top of the file you import all common settings:
from .base import *
Then you point the DJANGO_SETTINGS_MODULE
environment variable to the appropriate settings module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With