0
0
Djangoframework~5 mins

Security checklist (manage.py check --deploy) in Django

Choose your learning style9 modes available
Introduction

This command helps you find security issues in your Django project before you make it live. It checks important settings to keep your site safe.

Before launching your Django website to the public.
After changing security-related settings in your project.
When you want to review if your project follows Django's security best practices.
Before deploying updates to your live server.
Syntax
Django
python manage.py check --deploy

This command runs a set of security checks on your Django project.

It only checks settings related to deployment security, not your app logic.

Examples
Runs all security checks recommended for deployment.
Django
python manage.py check --deploy
Runs general system checks but does not include deployment security checks.
Django
python manage.py check
Sample Program

This example shows how the command warns you if DEBUG is True, which should be False in production. Fixing this removes the warning.

Django
1. Create a Django project named 'mysite'.
2. Open settings.py and set DEBUG = True.
3. Run: python manage.py check --deploy

# Output will warn about DEBUG being True, which is unsafe for deployment.

4. Change DEBUG = False in settings.py.
5. Run: python manage.py check --deploy

# Output will show no errors if other security settings are correct.
OutputSuccess
Important Notes

The command checks settings like DEBUG, SECRET_KEY, ALLOWED_HOSTS, SSL/HTTPS settings, and more.

Time complexity is minimal since it only reads settings and runs simple checks.

Common mistake: ignoring warnings and deploying with DEBUG = True or missing ALLOWED_HOSTS.

Use this command before deployment to catch security risks early.

Summary

Use manage.py check --deploy to find security issues before going live.

It helps ensure your Django settings are safe for production.

Fix warnings it shows to protect your site from common security problems.