Per-environment configuration

Per-environment configuration: Django settings (database, DEBUG, ALLOWED_HOSTS, secret key) vary between development, testing and production. You split them into several modules or read them from environment variables, never committing a secret to the repository. This avoids exposing debug mode or credentials in production.

Example

SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
DEBUG = os.environ.get('DJANGO_DEBUG') == '1'

Related concepts

The whole glossary