- β Django 5.2.8 - Latest stable version
- π¨ Tailwind CSS 4.1 - Modern utility-first CSS framework
- π Custom User Model - Email-based authentication ready
- π Environment Variables - Secure configuration management
- π Static & Media Files - Pre-configured file handling
- πΎ SQLite Database - Easy switch to PostgreSQL/MySQL
- π― Clean Structure - Well-organized apps and templates
- Features
- Prerequisites
- Quick Start
- Project Structure
- Configuration
- Tailwind CSS
- Common Commands
- Development Workflow
git clone https://github.com/PyBoilerplate/django-tailwindcss-template.git
cd django-tailwindcss-template# Create virtual environment
python -m venv .venv
# Activate virtual environment
# On macOS/Linux:
source .venv/bin/activate
# On Windows:
.venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the project root by copying the example:
cp .env.example .envEdit .env and configure your settings:
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhostπ‘ Tip: Generate a strong SECRET_KEY for production:
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
Run migrations to set up your database:
python manage.py migratepython manage.py createsuperuserpython manage.py runserverπ Success! Visit http://127.0.0.1:8000 to see your application!
π Admin panel: http://127.0.0.1:8000/admin
project_pyboilerplate_free_django_boilerplate/
βββ π app_main/ # Main application
β βββ migrations/
β βββ admin.py
β βββ models.py
β βββ views.py
β βββ urls.py
β
βββ π user/ # Custom user authentication app
β βββ migrations/
β βββ models.py # CustomUser model
β βββ forms.py # User forms
β βββ admin.py
β
βββ π project_pyboilerplate_free_django_boilerplate/
β βββ settings.py # Main settings file
β βββ urls.py # Root URL configuration
β βββ wsgi.py
β
βββ π templates/ # HTML templates
βββ π static/ # Static files (CSS, JS, images)
βββ π media/ # User-uploaded files
βββ π .env # Environment variables (not in git)
βββ π .env.example # Environment template
βββ π requirements.txt # Python dependencies
βββ π manage.py # Django management script
The project uses django-environ to manage configuration via environment variables:
| Variable | Description | Example |
|---|---|---|
SECRET_KEY |
Django secret key for cryptographic signing | your-secret-key-here |
DEBUG |
Debug mode (True for dev, False for prod) | True |
ALLOWED_HOSTS |
Comma-separated list of allowed hosts | 127.0.0.1,localhost |
Static Files Configuration
Developer-provided files (CSS, JavaScript, images):
STATIC_URL:/static/- URL prefix for static filesSTATICFILES_DIRS:static/- Development static filesSTATIC_ROOT:staticfiles/- Collected static files for production
Media Files Configuration
User-uploaded files:
MEDIA_URL:/media/- URL prefix for media filesMEDIA_ROOT:media/- Directory for uploaded files
Default configuration uses SQLite for development:
- Database file:
db.sqlite3 - Easy to switch to PostgreSQL/MySQL by updating
DATABASESinsettings.py
Custom user model configured in user/models.py:
- β Uses email instead of username for authentication
- β Customizable user fields
- β
Configured via
AUTH_USER_MODEL = 'user.CustomUser'
| App | Purpose |
|---|---|
app_main |
Main application for core functionality |
user |
Custom user authentication and profile management |
This project uses Tailwind CSS 4.1 for styling. Tailwind is configured using the standalone CLI for easy setup without Node.js dependencies.
To compile and watch Tailwind CSS during development:
# Run Tailwind in watch mode
npx @tailwindcss/cli -i ./static/tailwind/input.css -o ./static/tailwind/output.css --watch --minifyIn your HTML templates, include the compiled CSS:
{% load static %}
<!DOCTYPE html>
<html>
<head>
<link href="{% static 'src/output.css' %}" rel="stylesheet">
</head>
<body>
<div class="bg-blue-500 text-white p-4">
Hello, Tailwind!
</div>
</body>
</html>python manage.py startapp app_namepython manage.py makemigrations
python manage.py migratepython manage.py collectstaticpython manage.py testpython manage.py createsuperuserThis project is open source and available for use.
Happy Coding! π¨β¨
