A production-ready Django project template with modern best practices, custom user authentication, and Bootstrap 5 integration.
- Custom User Model with email-based authentication
- Modular Settings (base.py and prod.py configurations)
- Bootstrap 5 with jQuery and Popper.js from CDN
- Manifest Static Files Storage for production cache-busting
- Comprehensive .gitignore for Django projects
- Environment Variables support with python-dotenv
- Home App with base templates ready for customization
- Production-ready logging and security configurations
-
Clone or download this template:
git clone https://github.com/qcif/django-template.git cd django-template -
Initialize your project:
./init.sh
This script will:
- Prompt for your project name
- Replace all instances of "myproject" with your project name
- Rename directories appropriately
- Update configuration files
-
Set up your development environment:
cd your-project-name python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Configure environment variables:
cp .env.sample .env # Edit .env with your settings -
Run migrations and create superuser:
python manage.py migrate python manage.py createsuperuser
-
Start development server:
python manage.py runserver
your-project-name/
├── accounts/ # Custom user model app
│ ├── models.py # Email-based User model
│ └── ...
├── home/ # Home page app
│ ├── templates/home/ # Base templates
│ │ ├── header.html # Base template with Bootstrap
│ │ └── index.html # Homepage
│ └── ...
├── your-project-name/ # Main project directory
│ ├── settings/
│ │ ├── base.py # Base settings
│ │ ├── prod.py # Production settings
│ │ └── log/ # Logging configuration
│ ├── urls.py
│ └── wsgi.py
├── static/css/ # Static files
├── utils/ # Utility modules
├── manage.py
├── requirements.txt
├── .env.sample # Environment variables template
└── .gitignore
- Uses SQLite database
- Debug mode enabled
- Development-friendly configurations
- Loads from
.envfile
- Security headers enabled
- Manifest static files storage
- Production logging configuration
- SSL/HTTPS configurations
To use production settings:
export DJANGO_SETTINGS_MODULE=your_project_name.settings.prodCopy .env.sample to .env and configure:
# Required
SECRET_KEY=your-secret-key-here
HOSTNAME=your-domain.com
# Email (optional)
MAIL_HOSTNAME=smtp.example.com
MAIL_SMTP_PORT=587
[email protected]
MAIL_SMTP_PASSWORD=your-password
MAIL_USE_TLS=true
# reCAPTCHA (optional)
RECAPTCHA_SITE_KEY=your-site-key
RECAPTCHA_SECRET_KEY=your-secret-keyThe template includes a custom User model (accounts.User) that:
- Uses email as the username field
- Includes first_name, last_name fields
- Has proper UserManager for creating users and superusers
- Is properly configured in settings
- Bootstrap 5.3.0 loaded from CDN
- jQuery 3.7.1 for enhanced functionality
- Popper.js for Bootstrap components
- Local CSS file for custom styles (
static/css/main.css)
For production deployment:
- Set environment variables appropriately
- Use production settings:
your_project_name.settings.prod - Run
python manage.py collectstatic - Configure your web server (nginx/apache)
- Use a WSGI server like Gunicorn