What is Cookiecutter Django?
maincookiecutter tool.repository·main·Indexed 11 days ago
https://github.com/cookiecutter/cookiecutter-djangoA professional-grade project generator and Cookiecutter template for creating production-ready Django projects. Version 2026.8.9 supports Django 6.0 and Python 3.14, following 12-factor app principles with built-in configurations for security, testing (pytest), Celery, Sentry, and various cloud storage providers. It includes a flexible scaffolding process with options for REST APIs (DRF, Django Ninja), frontend pipelines, and Docker integration.
cookiecutter tool.Cookiecutter Django provides a production-ready foundation with the following built-in features:
unittest or pytest support.django-environ.django-allauth.Anymail integration (Mailgun default, switchable to Amazon SES).docker-compose (using Traefik and LetsEncrypt), Procfile for Heroku, and instructions for PythonAnywhere.pre-commit integration for linting and issue identification.compilemessages. Ensure your translated .po source files are up-to-date in your repository before building the production image.Cookiecutter Django uses django-allauth for authentication, which is configured by default to require email verification. This means the system will attempt to send a verification email in the following scenarios:
Because these actions trigger an email, ensure your email provider (like Mailgun) is fully configured and authorized to prevent application errors during the authentication flow.
django.contrib.sites directory to automate the configuration of the sites.Site record. Instead of manually updating the site domain and name from the default example.com, the project uses a migration (0003_set_site_domain_and_name.py) to inject the values provided during the cookiecutter generation process: {{cookiecutter.domain_name}} for the domain and {{cookiecutter.project_name}} for the name.During initial setup, you can enable several optional integrations to extend your project's capabilities:
Whitenoise.Celery and Flower (Flower is available in Docker setups).Mailpit or Mailtrap Local for local development.Sentry.Two Scoops of Django 3.x. This is because Cookiecutter Django serves as a test bed for experimenting with new Django architectural ideas and concepts, which may result in deviations from the established patterns in the book.HTTPS is enabled by default using the Traefik reverse proxy, which automatically obtains and updates SSL certificates from Let's Encrypt.
Requirements for Automatic HTTPS:
DJANGO_ALLOWED_HOSTS environment variable before deploying. Failure to do this will prevent access via HTTP/HTTPS.The docker-compose.production.yml file defines a multi-service stack. The services included depend on your project configuration:
django: The application running behind Gunicorn.postgres: PostgreSQL database for relational data.redis: Redis instance used for caching.traefik: Reverse proxy that handles HTTPS by default.use_celery=y was selected)celeryworker: Runs Celery worker processes.celerybeat: Runs the Celery beat scheduler.flower: A monitoring tool served via Traefik over HTTPS on port 5555.When using a cloud provider for storage, the template uses a single bucket (or container) to hold both static files and user uploads, distinguished by prefixes:
static/: Contains the output of collectstatic. These files are intended to be publicly readable.media/: Contains user uploads served via MEDIA_URL.Important Security Note: The template does not set per-object ACLs. Objects inherit the bucket's access rules. If you grant public read access to the entire bucket, your media/ files will also be publicly accessible. If your uploads are sensitive, follow the Keeping media private guidelines.
If use_docker and use_celery were enabled during project initialization, a flower service is provided for real-time monitoring of the Celery task queue.
http://localhost:5555CELERY_FLOWER_USER and CELERY_FLOWER_PASSWORD environment variables defined in .envs/.local/.django (for local) or .envs/.production/.django (for production).If you use Webpack without Whitenoise, Webpack needs to know the static URL at build time. Because Docker does not read the .envs/.production/.django file during the build phase (it only looks for a .env file in the root), you must provide the static URL variables during the build command.
Required Environment Variables:
AWS_STORAGE_BUCKET_NAME (or DJANGO_AWS_S3_CUSTOM_DOMAIN)DJANGO_GCP_STORAGE_BUCKET_NAME (or DJANGO_GCP_STORAGE_BUCKET_NAME)DJANGO_AZURE_CONTAINER_NAME (or DJANGO_AZURE_CONTAINER_NAME)Recommended Solution: Pass the variables directly to the build command:
DJANGO_AWS_S3_CUSTOM_DOMAIN=example.com docker compose -f docker-compose.production.yml build