Django. Using multiple settings files with Heroku

后端 未结 2 475
生来不讨喜
生来不讨喜 2020-12-29 06:39

I am trying to follow the advice of the book \"Two Scoops of Django\" and although it is a really good book, I think it this section is unclear. So, I split my settings fil

相关标签:
2条回答
  • 2020-12-29 07:06

    After you have logged into heroku with heroku login you can check your configs by running: heroku config. If you dont see a SECRET_KEY and DJANGO_SETTINGS_MODULE you can set them by running:

    heroku config:set SECRET_KEY='secret_key_goes_here'
    

    and

    heroku config:set DJANGO_SETTINGS_MODULE=mysite.settings.production
    

    Finally, make sure that you have the following syntax inside of your production setting file:

    SECRET_KEY = os.environ['SECRET_KEY']
    

    The above intstructions are for the following project structure

    -myproject
      -app1
      -app2
      -mysite
        -settings
          __init__.py
          base.py
          dev.py
          production.py
    -manage.py
    -Pipfile
    -Procfile
    -requirements.txt
    
    0 讨论(0)
  • 2020-12-29 07:18

    You can use the environment variable DJANGO_SETTINGS_MODULE to specify a default settings module:

    https://docs.djangoproject.com/en/dev/topics/settings/#envvar-DJANGO_SETTINGS_MODULE

    On local Linux machine:

    export DJANGO_SETTINGS_MODULE=settings.local
    

    On Heroku:

    heroku config:set DJANGO_SETTINGS_MODULE=settings.production
    
    0 讨论(0)
提交回复
热议问题