- Python
- Django
- Django Rest Framework
- Docker
- Postgresql
- Redis
- Celery
- Ruff
- Caddy
This template is thought and designed for the docker environment. It is not recommended to use it without docker.
- create a file named
.env
containing the required environment variables (read the next section) - run
docker compose up --build
for dev ordocker compose -f docker-compose.prod.yml up --build
for prod - work with your local files
- execute commands inside the container. ex
docker exec -it django-template-app-1 python manage.py makemigrations
Use Ruff to check the code quality. ruff
command is already installed inside the container.
Example: docker exec -it django-template-app-1 ruff check .
Features | |
---|---|
Auto-reload | ❌ No |
Auto migrate at start | ✅ |
Auto requirements install at start | ✅ |
Database | MariaDB |
Database port publicly exposed | ✅ |
Reverse proxy (Caddy) | |
Debug | |
Admin page | ✅ |
Serving media automatically | ✅ |
CORS allow all | ❌ No (default=localhost) |
Allow all hosts | ❌ No (default=localhost) |
There is google oauth2 authentication already implemented with django-allauth. You have to create a google oauth2 app and add the credentials to the admin page.
To generate the schema.yml file run inside the container
python manage.py spectacular --color --file schema.yml
or outside the container
docker exec -it django-template-app-1 python manage.py spectacular --color --file schema.yml
- ✅ Required
- ❌ Not required
⚠️ Optional
Variables | |
---|---|
DJANGO_SETTINGS_MODULE | ✅ |
DB_NAME | ✅ |
DB_USERNAME | ✅ |
DB_PASSWORD | ✅ |
DB_HOSTNAME | ✅ |
DB_PORT | ✅ |
SECRET_KEY | |
EMAIL_HOST | |
EMAIL_HOST_PASSWORD | |
EMAIL_HOST_USER | |
EMAIL_PORT | |
GOOGLE_CLIENT_ID | |
GOOGLE_CLIENT_SECRET | |
APPLE_CLIENT_ID | |
APPLE_CLIENT_SECRET | |
APPLE_KEY | |
DEBUG | |
DJANGO_ALLOWED_HOSTS | ✅ |
DJANGO_CORS_ALLOWED_ORIGINS | ✅ |
DJANGO_CSRF_TRUSTED_ORIGINS | ✅ |
CELERY_BROKER_URL | ✅ |
CELERY_RESULT_BACKEND | ✅ |
REDIS_BACKEND | ✅ |
CADDY_PORT | ✅ |
CADDY_EMAIL | ✅ |
DOMAIN | ✅ |
DJANGO_SETTINGS_MODULE=core.config.settings.development (or .production)
SECRET_KEY=anotherrandomstring
EMAIL_HOST=smtp.gmail.com
EMAIL_HOST_PASSWORD=gmailpassword (Turn ON two factor authentication of gmail account, and create an app password - https://support.google.com/accounts/answer/185833)
[email protected] (gmail_username)
EMAIL_PORT=587
GOOGLE_CLIENT_ID=32193185322-05a6v4duc3cqhk25mjdc015g2903kr1n.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
APPLE_CLIENT_ID=com.example.app
APPLE_CLIENT_SECRET=applesecret
APPLE_KEY=applekey
DB_NAME=somerandomname
DB_USERNAME=somerandomusername
DB_PASSWORD=somerandomstring
DB_HOSTNAME=database
DB_PORT=5432
DEBUG=True
DJANGO_ALLOWED_HOSTS=*
DJANGO_CORS_ALLOWED_ORIGINS=http://localhost:5000
DJANGO_CSRF_TRUSTED_ORIGINS=http://localhost:5000
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
REDIS_BACKEND=redis://redis:6379/0
CADDY_PORT=80
[email protected]
DOMAIN=example.com
STRIPE_PUBLISHABLE_KEY=stripekey
STRIPE_SECRET_KEY=stripesecret