How to manage local vs production settings in Django?

前端 未结 22 2108
别跟我提以往
别跟我提以往 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:04

    As an alternative to maintain different file if you wiil: If you are using git or any other VCS to push codes from local to server, what you can do is add the settings file to .gitignore.

    This will allow you to have different content in both places without any problem. SO on server you can configure an independent version of settings.py and any changes made on the local wont reflect on server and vice versa.

    In addition, it will remove the settings.py file from github also, the big fault, which i have seen many newbies doing.

提交回复
热议问题