Elegantly handle site-specific settings/configuration in svn/hg/git/etc?

后端 未结 4 1166
小蘑菇
小蘑菇 2020-12-14 16:30

I\'ve been looking for a better way to deal with site-specific settings (in this case, the django settings.py file).

The settings.py structure and fields are fairly

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 17:13

    The way I handle this is to have a base settings.py file and then a settings file for each environment (eg dev_settings.py, live_settings.py)

    At the top of each environment specific file I have

    from settings import *
    

    I can then simply override any settings I need to change on an environment specific basis

    To ensure each environment uses the correct settings I just modify the DJANGO_SETTINGS_MODULE environment variable. How you do this depends how you are deploying django (mod_wsgi, mod_python and so on...)

提交回复
热议问题