You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
sina_sajjadi 98bcc2f2a6 feat: add Django Unfold admin configurations for applications and custom base template 3 days ago
apps feat: add Django Unfold admin configurations for applications and custom base template 3 days ago
centrifugo feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
config feat: add Django Unfold admin configurations for applications and custom base template 3 days ago
dynamic_preferences feat: add core backend application structure, enhanced auth middleware, and API components 4 weeks ago
locale feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
nginx feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
templates feat: add Django Unfold admin configurations for applications and custom base template 3 days ago
test_media feat: introduce search app and add new account and api views 3 weeks ago
utils feat: add Django Unfold admin configurations for applications and custom base template 3 days ago
.dockerignore feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
.env.dev feat: add project base settings, Redis configuration, and user authentication endpoints 3 weeks ago
.env.example feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
.env.prod feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
.gitignore feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
Dockerfile feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
Dockerfile.prod feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
README.md feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
db.sqlite3.backup feat: add global institutions seed command and migration for user first and last names 4 days ago
docker-compose.prod.yml feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
docker-compose.yml feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
dump.rdb feat: add global institutions seed command and migration for user first and last names 4 days ago
entrypoint.sh feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
manage.py feat: add authentication serializers, views, account admin modules, and local configuration settings 3 weeks ago
package-lock.json feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
package.json feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago
requirements.txt feat: introduce search app and add new account and api views 3 weeks ago
schema.yml feat: add global institutions seed command and migration for user first and last names 4 days ago
tailwind.config.js feat: initialize Django backend project structure with core apps, API views, and configurations 4 weeks ago

README.md

Django Backend Starter Template

A modern, production-ready, batteries-included Django backend template built for rapid application development.


๐Ÿš€ Tech Stack

  • Framework: Django 5.0+
  • API Engine: Django REST Framework (DRF)
  • Admin Interface: Django Unfold (Tailwind-based modern UI)
  • Database: PostgreSQL
  • Caching & Broker: Redis
  • Task Queue: Celery & Celery Beat
  • API Documentation: Swagger UI & ReDoc via drf-yasg
  • Static Assets: WhiteNoise
  • Containerization: Docker & Docker Compose

๐ŸŒŸ Key Features

  1. Custom User Authentication (apps/account):
    • Email-based authentication (no cumbersome usernames).
    • Profile management with avatar, phone number, and metadata.
    • Built-in LoginHistory and LocationHistory tracking.
    • Standard authentication endpoints (Register, Login, Token Exchange, Password Reset, Profile Update).
    • Clean group and role-based permissions.
  2. Modern Admin Panel (utils/admin.py & Django Unfold):
    • Modern Tailwind styling with dark/light mode.
    • Dynamic Dashboard KPI statistics.
    • Responsive sidebar with configurable navigation.
  3. Interactive API Documentation (apps/api):
    • Live Swagger UI at /swagger/ and ReDoc at /redoc/.
    • Token authentication banner for test requests.
    • Health check endpoint at /api/v1/health/.
    • Mobile app release versioning (AppVersion).
  4. Runtime Dynamic Preferences (dynamic_preferences/):
    • Editable site-wide settings directly from the admin panel (site title, contact email, maintenance mode).
  5. Production Ready:
    • Multi-stage Dockerfile and Docker Compose setup.
    • Nginx reverse proxy configuration.
    • Pre-configured Gzip compression, security headers, and media streaming.

๐Ÿ“ Project Structure

โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ account/              # Custom User, authentication, profile, notifications
โ”‚   โ”‚   โ”œโ”€โ”€ admin/            # Unfold user and group admin
โ”‚   โ”‚   โ”œโ”€โ”€ migrations/       # Initial schema migrations
โ”‚   โ”‚   โ”œโ”€โ”€ models/           # User, LoginHistory, Notification models
โ”‚   โ”‚   โ”œโ”€โ”€ serializers/      # DRF serializers for user & auth
โ”‚   โ”‚   โ”œโ”€โ”€ views/            # Register, login, profile, notification views
โ”‚   โ”‚   โ””โ”€โ”€ urls.py           # Account API endpoints
โ”‚   โ””โ”€โ”€ api/                  # Core API utilities, versions, health checks
โ”‚       โ”œโ”€โ”€ admin/            # Version & support admin
โ”‚       โ”œโ”€โ”€ migrations/       # Initial schema migrations
โ”‚       โ”œโ”€โ”€ models/           # AppVersion, SupportMessage
โ”‚       โ”œโ”€โ”€ serializers/      # API serializers
โ”‚       โ”œโ”€โ”€ views/            # HealthCheck, AppVersion, Swagger views
โ”‚       โ””โ”€โ”€ urls.py           # Core API routes
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ settings/
โ”‚   โ”‚   โ”œโ”€โ”€ base.py           # Base Django settings
โ”‚   โ”‚   โ”œโ”€โ”€ develop.py        # Development settings
โ”‚   โ”‚   โ”œโ”€โ”€ production.py     # Production settings
โ”‚   โ”‚   โ””โ”€โ”€ test.py           # Test settings
โ”‚   โ”œโ”€โ”€ celery.py             # Celery worker configuration
โ”‚   โ”œโ”€โ”€ urls.py               # Root URL configuration
โ”‚   โ”œโ”€โ”€ wsgi.py               # WSGI entry point
โ”‚   โ””โ”€โ”€ asgi.py               # ASGI entry point
โ”œโ”€โ”€ dynamic_preferences/       # In-tree runtime preferences registry
โ”œโ”€โ”€ nginx/
โ”‚   โ””โ”€โ”€ app.conf              # Nginx reverse proxy config
โ”œโ”€โ”€ static/                   # Static CSS and JS assets
โ”œโ”€โ”€ templates/
โ”‚   โ”œโ”€โ”€ admin/                # Unfold admin dashboard & overrides
โ”‚   โ””โ”€โ”€ swagger/              # Custom Swagger UI templates
โ”œโ”€โ”€ utils/                    # Reusable helper modules
โ”‚   โ”œโ”€โ”€ admin.py              # Unfold AdminSite and dashboard callbacks
โ”‚   โ”œโ”€โ”€ exceptions.py         # DRF custom exception handler
โ”‚   โ”œโ”€โ”€ image_compression.py  # Image optimization
โ”‚   โ”œโ”€โ”€ pagination.py         # Standard REST pagination
โ”‚   โ””โ”€โ”€ redis.py              # Redis token and cache helpers
โ”œโ”€โ”€ .env.example              # Environment variables template
โ”œโ”€โ”€ .env.dev                  # Local development env defaults
โ”œโ”€โ”€ docker-compose.yml        # Docker compose configuration
โ”œโ”€โ”€ Dockerfile                # Docker build file
โ”œโ”€โ”€ manage.py                 # Django CLI
โ””โ”€โ”€ requirements.txt          # Python dependencies

๐Ÿ› ๏ธ Quick Start

  1. Clone or copy the template:

    git init my-project
    cd my-project
    
  2. Setup environment variables:

    cp .env.example .env.dev
    
  3. Build and start services:

    docker compose up -d --build
    
  4. Run migrations and create superuser:

    docker compose exec web python manage.py migrate
    docker compose exec web python manage.py createsuperuser
    
  5. Access the app:


2. Local Python Environment

  1. Create and activate a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Configure environment:

    cp .env.example .env
    # Edit .env with your local PostgreSQL and Redis credentials
    
  4. Apply migrations:

    python manage.py migrate
    python manage.py createsuperuser
    
  5. Run the development server:

    python manage.py runserver
    

๐Ÿ”‘ Environment Variables Reference

Variable Description Default
DJANGO_SECRET_KEY Unique Django secret key (Required in production)
DJANGO_DEBUG Enable debug mode True
DJANGO_ALLOWED_HOSTS Comma-separated allowed hostnames 127.0.0.1,localhost
POSTGRES_DB PostgreSQL database name app_db
POSTGRES_USER PostgreSQL user postgres
POSTGRES_PASSWORD PostgreSQL password postgres
POSTGRES_HOST PostgreSQL host postgres / localhost
POSTGRES_PORT PostgreSQL port 5432
REDIS_URL Redis connection URL redis://redis:6379/0
SENTRY_DSN Sentry error tracking DSN (Optional)

๐Ÿ“ก API Endpoints Overview

  • Auth & Account:
    • POST /api/v1/account/register/ - User registration
    • POST /api/v1/account/login/ - User login & token generation
    • GET /api/v1/account/profile/ - Authenticated user profile
    • PUT /api/v1/account/profile/update/ - Update profile
    • POST /api/v1/account/recover/ - Request password recovery
    • POST /api/v1/account/reset/ - Reset password
  • System & Utilities:
    • GET /api/v1/health/ - Server health status
    • GET /api/v1/version/ - Latest mobile application version
    • POST /api/v1/contact-us/ - Submit support/contact message
  • Documentation:
    • /swagger/ - Interactive Swagger UI
    • /redoc/ - ReDoc API documentation