How to manage local vs production settings in Django?

前端 未结 22 2047
别跟我提以往
别跟我提以往 2020-11-22 15:00

What is the recommended way of handling settings for local development and the production server? Some of them (like constants, etc) can be changed/accessed in both, but s

22条回答
  •  孤独总比滥情好
    2020-11-22 15:29

    In settings.py:

    try:
        from local_settings import *
    except ImportError as e:
        pass
    

    You can override what needed in local_settings.py; it should stay out of your version control then. But since you mention copying I'm guessing you use none ;)

提交回复
热议问题