🚀 Production-Ready Django Folder Structure Guide
Jan 22, 2026 | By Pavan Mehta

🚀 Production-Ready Django Folder Structure Guide

A scalable Django project structure is essential for team collaboration, clean deployments, and long-term maintenance. This guide shares a battle-tested, production-ready Django folder structure that supports:

  • ✅ Multiple environments (Dev / Prod)
  • ✅ Docker & Nginx deployment
  • ✅ Django REST Framework (DRF)
  • ✅ Clean app separation & scalability

📂 Complete Project Folder Structure


nanostack_project/
├── manage.py                    # Django management script
├── requirements.txt             # Python dependencies
├── .env                         # Environment variables
├── .gitignore                   # Git exclusions
├── README.md                    # Project documentation
├── docker-compose.yml           # Container orchestration
├── nginx.conf                   # Production web server config
└── nanostack_project/           # Main Django settings directory
    ├── __init__.py
    ├── settings/
    │   ├── __init__.py
    │   ├── base.py              # Common settings
    │   ├── development.py       # Development environment
    │   └── production.py        # Production environment
    ├── urls.py                  # Main URL configuration
    ├── wsgi.py                  # WSGI entry point
    └── asgi.py                  # ASGI entry point
├── apps/                        # All Django applications
│   ├── core/
│   ├── users/
│   └── products/
├── staticfiles/                 # Collected static files
├── media/                       # User uploads
└── templates/                   # Global templates
  

📌 Why this matters:
This structure keeps your project clean, modular, and production-safe as it grows.


🧠 Key Architecture Decisions

1️⃣ Centralized Settings Management

Instead of a single settings.py, split your configuration:


nanostack_project/settings/
├── base.py
├── development.py
└── production.py
  

Example: development.py


from .base import *

DEBUG = True

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}
  
  • ✅ Prevents environment leaks
  • ✅ Cleaner production deployments
  • ✅ Easy debugging and scaling

2️⃣ Apps Directory Pattern

All Django apps live inside the apps/ directory:

  • ✔ Each app is self-contained
  • ✔ Clear separation of concerns
  • ✔ Easier testing and reuse

Create apps like this:


python manage.py startapp core apps/core
  

3️⃣ Production Deployment Ready

This structure is deployment-first, not an afterthought:


├── docker-compose.yml
├── nginx.conf
├── deploy/
└── gunicorn_service
  

💡 Works smoothly with:

  • Docker
  • Gunicorn
  • Nginx
  • Redis
  • PostgreSQL

🔐 Environment Variables (.env)

Never hardcode secrets. Always use environment variables.


SECRET_KEY=your-secret-key-here
DEBUG=True
DATABASE_URL=sqlite:///db.sqlite3
ALLOWED_HOSTS=localhost,127.0.0.1
  

🚫 Never commit .env files to Git


📦 requirements.txt (Production-Safe)


Django==5.1.2
djangorestframework==3.15.2
python-decouple==3.8
gunicorn==22.0.0
psycopg2-binary==2.9.9
redis==5.0.1
channels==4.1.0
  
  • ✔ Stable versions
  • ✔ Production tested
  • ✔ API-ready

⚙️ Essential base.py Settings


from decouple import config
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'apps.core',          # Your apps first
    'rest_framework',
]

STATIC_ROOT = BASE_DIR / 'staticfiles'
MEDIA_ROOT = BASE_DIR / 'media'
  

📌 Keep shared settings only in base.py.


🚀 Deployment Commands

🔧 Development


pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
  

🌐 Production


docker-compose up -d
python manage.py collectstatic --noinput
sudo nginx -t && sudo systemctl restart nginx
  

🔄 Migrating Existing Django Projects

✔ Move apps:


mv core apps/core
  
  • ✔ Split settings into environments
  • ✔ Update manage.py & wsgi.py
  • ✔ Run final check:

python manage.py check --deploy
  

✅ Best Practices Checklist

  • ✔ Never commit .env files
  • ✔ Each app has its own templates/app_name/
  • collectstatic works without errors
  • ✔ Settings are environment-specific
  • ✔ Docker includes nginx, gunicorn, redis, postgres

🎯 Final Thoughts

This folder structure scales smoothly from:

  • Freelance projects
  • Startups
  • Enterprise-grade Django applications

All while staying true to Django’s “batteries-included” philosophy.

🌍 Perfect for Rajkot’s growing tech ecosystem
💬 Share your improvements with the community!


🏷️ Credits

Maintained by NanoStack Technologies
🌐 https://www.nanostacktechnologies.com