Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks. USE WHEN validating a Django change before a PR or release, or running the full pre-ship gate of migrations, lint, tests, and security.
Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks. USE WHEN validating a Django change before a PR or release, or running the full pre-ship gate of migrations, lint, tests, and security.
origin
ECC
cluster
python-backend
version
1.0.0
Django Verification Loop
Run before PRs, after major changes, and pre-deploy to ensure Django application quality and security.
When to Activate
Before opening a pull request for a Django project
After major model changes, migration updates, or dependency upgrades
Pre-deployment verification for staging or production
Running full environment → lint → test → security → deploy readiness pipeline
Validating migration safety and test coverage
Phase 1: Environment Check
# Verify Python version
python --version # Should match project requirements# Check virtual environmentwhich python
pip list --outdated
# Verify environment variables
python -c
# Run all tests with pytest
pytest --cov=apps --cov-report=html --cov-report=term-missing --reuse-db
# Run specific app tests
pytest apps/users/tests/
# Run with markers
pytest -m "not slow"# Skip slow tests
pytest -m integration # Only integration tests# Coverage report
open htmlcov/index.html
# Django Debug Toolbar output (check for N+1 queries)# Run in dev mode with DEBUG=True and access a page# Look for duplicate queries in SQL panel# Query count analysis
django-admin debugsqlshell # If django-debug-sqlshell installed# Check for missing indexes
python manage.py shell << EOF
from django.db import connection
with connection.cursor() as cursor:
cursor.execute("SELECT table_name, index_name FROM information_schema.statistics WHERE table_schema = 'public'")
print(cursor.fetchall())
EOF
Report:
Number of queries per page (should be < 50 for typical pages)
Missing database indexes
Duplicate queries detected
Phase 8: Static Assets
# Check for npm dependencies (if using npm)
npm audit
npm audit fix
# Build static files (if using webpack/vite)
npm run build
# Verify static filesls -la staticfiles/
python manage.py findstatic css/style.css
Phase 9: Configuration Review
# Run in Python shell to verify settings
python manage.py shell << EOF
from django.conf import settings
import os
# Critical checks
checks = {
'DEBUG is False': not settings.DEBUG,
'SECRET_KEY set': bool(settings.SECRET_KEY andlen(settings.SECRET_KEY) > 30),
'ALLOWED_HOSTS set': len(settings.ALLOWED_HOSTS) > 0,
'HTTPS enabled': getattr(settings, 'SECURE_SSL_REDIRECT', False),
'HSTS enabled': getattr(settings, 'SECURE_HSTS_SECONDS', 0) > 0,
'Database configured': settings.DATABASES['default']['ENGINE'] != 'django.db.backends.sqlite3',
}
for check, result in checks.items():
status = '✓'if result else'✗'print(f"{status}{check}")
EOF