Django settings from .env
Load variables with python-dotenv or django-environ and read them in settings.py, e.g. SECRET_KEY = os.environ["SECRET_KEY"].
Production checklist
Set DEBUG=False, list your real domains in ALLOWED_HOSTS and use a unique SECRET_KEY per environment. Never commit it.
Frequently asked questions
How long should a Django SECRET_KEY be?
At least 50 characters is recommended. The alphanumeric option generates 40, so choose Hex (64) from Secret type for a longer key.
Does it work with django-environ?
Yes, the DATABASE_URL format is compatible.