Dotenv
November 23, 2024•316 words
1. Installing dotenv
To keep your your secret_key and other sensitive stuff (like database connection) out of your git repo, you can use a .env file to put them in.
When you've activated your virtual environment, install python-dotenv. This tool will help Django to read settings from your .env file.
pip install python-dotenv
2. Create a .env file
In your Django project's main folder, create a .env file. A very simple version could look like this:
ALLOWED_HOSTS = localhost myhost someotherhos...
Read post