A professional, reusable Django REST Framework template for building scalable and maintainable APIs.
- Modular app structure with clear separation of concerns
- Custom user model with authentication system
- JWT authentication
- Standardized API response formatting
- Environment-based configuration
- Docker setup for development and production
- Comprehensive test setup
- API documentation with drf-spectacular (Swagger/OpenAPI)
- Logging and monitoring
- Security best practices
django-drf-template/
│
├── .github/ # GitHub specific files
├── config/ # Project configuration
├── apps/ # Django applications
│ ├── core/ # Core functionality shared across apps
│ ├── users/ # User management app
│ ├── authentication/ # Authentication app
│ └── api/ # Main API app
├── templates/ # HTML templates (if needed)
├── static/ # Static files
├── media/ # User-uploaded files
├── docs/ # Project documentation
├── scripts/ # Utility scripts
├── requirements/ # Python dependencies
└── docker/ # Docker configuration
- Python 3.8+
- PostgreSQL
- Docker and Docker Compose (optional)
-
Clone the repository:
git clone https://github.com/yourusername/django-drf-template.git cd django-drf-template -
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies:
pip install -r requirements/development.txt -
Create a
.envfile from the example:cp .env.example .env -
Run migrations:
python manage.py migrate -
Create a superuser:
python manage.py createsuperuser -
Run the development server:
python manage.py runserver
-
Build and start the containers:
docker-compose up -d --build -
Run migrations:
docker-compose exec web python manage.py migrate -
Create a superuser:
docker-compose exec web python manage.py createsuperuser
API documentation is available at /api/docs/ when the server is running.
Run tests with:
python manage.py test
Or with coverage:
coverage run --source='.' manage.py test
coverage report
See the deployment guide in the docs/deployment/ directory for detailed instructions.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.