Django 3 Web Development Cookbook
上QQ阅读APP看书,第一时间看更新

How it works...

If you run a Django management command without the environment variable set, you will see an error raised with a message, such as Set the DJANGO_SECRET_KEY environment variable.

You can set the environment variables in the PyCharm configuration, remote server configuration consoles, in the env/bin/activate script, .bash_profile, or directly in the Terminal like this:

$ export DJANGO_SECRET_KEY="change-this-to-50-characters-long-random-
string"

$ export DATABASE_NAME="myproject"
$ export DATABASE_USER="myproject"
$ export DATABASE_PASSWORD="change-this-to-database-password"

Note that you should use the get_secret() function for all passwords, API keys, and any other sensitive information that you need in your Django project configuration.