📝 Django

Django: Production Checklist

P
Author
Pyland
📅
Published
30.06.2026
⏱️
Reading time
1 min
👁️
Views
77
🌳
Level
Advanced

Use PostgreSQL, not SQLite.

Security

# settings.py
DEBUG = False
SECRET_KEY = os.environ['SECRET_KEY']  # from environment variable
ALLOWED_HOSTS = ['yourdomain.com']

# HTTPS
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True

# Clickjacking protection
X_FRAME_OPTIONS = 'DENY'

Database

DATABASES = {
    'default': dj_database_url.config(conn_max_age=600)
}

Use PostgreSQL, not SQLite.

Static Files

pip install whitenoise
MIDDLEWARE = ['whitenoise.middleware.WhiteNoiseMiddleware', ...]
STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
python manage.py collectstatic --no-input

Logging

LOGGING = {
    'version': 1,
    'handlers': {
        'console': {'class': 'logging.StreamHandler'},
    },
    'root': {'handlers': ['console'], 'level': 'WARNING'},
}

Media Files

Do not store media files on the server — use S3 or an equivalent:

pip install django-storages boto3

Error Monitoring

pip install sentry-sdk
import sentry_sdk
sentry_sdk.init(dsn=os.environ['SENTRY_DSN'])

Deployment Check Command

python manage.py check --deploy

This will output a list of security issues to address.

Checklist

  • [ ] DEBUG = False
  • [ ] SECRET_KEY loaded from environment variable
  • [ ] PostgreSQL instead of SQLite
  • [ ] collectstatic has been run
  • [ ] HTTPS configured
  • [ ] Migrations applied
  • [ ] Superuser created
  • [ ] Logging configured
  • [ ] Sentry connected

Your reaction to the article

💬 Comments (0)

🔐 Sign in to leave a comment
🚪 Login
💭

No comments yet

Be the first to share your opinion about this article!

🔗 Similar

Similar articles

Continue learning with these materials

📝

pytest-django: Testing Django

Охватываемые темы: Installation, @pytest.mark.djangodb, Fixtures, Testing views.

📅 30.06.2026 👁️ 132
📝

Django: Template Tags

Template tags are logic inside HTML. Unlike {{ variable }} which only outputs a value,...

📅 30.06.2026 👁️ 84
📝

HTML Lists

Lists are one of the most common markup elements. Navigation menus, post tags, how-to steps,...

📅 30.06.2026 👁️ 84

Did you like the article?

Subscribe to our updates and receive new articles first. Grow with PyLand!