How to properly runserver on different settings for Django?

前端 未结 7 864
悲哀的现实
悲哀的现实 2021-02-07 14:42

I have a basic django rest API. I want to separate some of my settings for dev and prod just for organizational purposes. I\'m also just learning about separating environments.

7条回答
  •  北荒
    北荒 (楼主)
    2021-02-07 15:42

    What I've always done is on the local env create a file called local_settings.py that can have it's own database settings, static path and so on and at the end of the settings file include this

    try:
        from local_settings import *#
    except:
        pass
    

    so on the server I always make sure not to import the local_settings and it separates the two nicely.

提交回复
热议问题