Where do I set environment variables for Django?

前端 未结 4 1735
小鲜肉
小鲜肉 2020-12-09 11:11

everyone!

Django 1.11 + PostgreSQL 9.6 + Gunicorn + Ubuntu 16.04 in AWS

I want to set environment variables for sensitive info.(django secret key, DB passwor

4条回答
  •  既然无缘
    2020-12-09 11:22

    If you're using a virtual ENV you can add the environment variables to that specific environment. You can use export KEY=VALUE in your terminal but that will not persist. If you would like your values to persist you can edit the file:

    sudo nano your_environment/bin/activate

    Then at the bottom add the values you want e.g.:

    export MY_KEY="12345"

    And save. Remember to restart your ENV for changes to take effect.

提交回复
热议问题