How to properly runserver on different settings for Django?

前端 未结 7 869
悲哀的现实
悲哀的现实 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:32

    Put all your common configurations in the commonsettings.py file.

    add following the line into the __init__.py file in the settings directory

    from commonsettings import *
    

    This makes every configuration in the commonsettings file available in all other files in the settings folder

    start your server with

    python3 manage.py runserver --settings=djangorest.settings.dev
    

提交回复
热议问题