๐Ÿ“ Django

Django: Production Checklist

P
Author
PyLand Team
๐Ÿ“…
Published
30.06.2026
โฑ๏ธ
Reading time
1 min
๐Ÿ‘๏ธ
Views
292
๐ŸŒณ
Level
Advanced

Before deploying a Django project, review its security, database, static files, HTTPS, logging, and backup settings.

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

๐Ÿ“

settings.py: Django Configuration

settings.py is the central configuration file for a Django project.

๐Ÿ“… 30.06.2026 ๐Ÿ‘๏ธ 315
๐Ÿ“

DRF ViewSets and Routers

ViewSet is a class that combines several related views into one. Router automatically generates URLs.

๐Ÿ“… 30.06.2026 ๐Ÿ‘๏ธ 284
๐Ÿ“

Pagination in Django ListView

Covered topics: Enabling pagination, Template with pagination, Pagination with filters, Manual pagination (in function-based views).

๐Ÿ“… 30.06.2026 ๐Ÿ‘๏ธ 353
๐ŸŽ“ Continue learning

Courses that cover this material

Visit the course to apply this material in practice.

Django RequestLab: from HTTP to secure production Open course curriculum