Skip to content

leen2233/drf-project-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django REST Framework Project Template

A batteries-included Django REST Framework template to kickstart your API development with best practices and common configurations out of the box.

✨ Features

  • Pre-configured Django REST Framework with Token Authentication
  • Environment-based Settings using python-dotenv
  • Database Flexibility
    • SQLite (default)
    • PostgreSQL support built-in
  • Enhanced Admin Interface with Django Jazzmin
  • API Documentation with drf-yasg (Swagger/OpenAPI)
  • CORS Configuration ready for frontend integration
  • Project Renaming Utility included
  • Security Features pre-configured
    • CSRF protection
    • Proper security settings
    • Environment-based DEBUG mode

🚀 Quick Start

  1. Clone this repository:
git clone https://github.com/leen2233/drf-project-template.git
cd drf-project-template
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file in the project root:
SECRET_KEY=your-secret-key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:3000
CSRF_TRUSTED_ORIGINS=http://localhost:3000

# Database configuration (optional)
DATABASE_PROVIDER=sqlite3  # or postgres
POSTGRES_DB=your_db_name
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
  1. Rename the project (optional):
python manage.py rename_project your_project_name
  1. Run migrations:
python manage.py migrate
  1. Create a superuser:
python manage.py createsuperuser
  1. Run the development server:
python manage.py runserver

📁 Project Structure

project/
├── app/                    # Main application directory
│   ├── management/        # Custom management commands
│   └── urls.py           # Application URLs
├── project/              # Project configuration directory
│   ├── settings.py       # Project settings
│   ├── urls.py          # Project URL configuration
│   ├── wsgi.py          # WSGI configuration
│   └── asgi.py          # ASGI configuration
├── .env                   # Environment variables
├── manage.py             # Django management script
└── requirements.txt      # Project dependencies

🛠️ Included Packages

⚙️ Configuration

Database Configuration

The project supports both SQLite and PostgreSQL out of the box. To use PostgreSQL:

  1. Set in your .env:
DATABASE_PROVIDER=postgres
POSTGRES_DB=your_db_name
POSTGRES_USER=your_db_user
POSTGRES_PASSWORD=your_db_password
POSTGRES_HOST=localhost
POSTGRES_PORT=5432

CORS Configuration

Configure CORS in your .env:

CORS_ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
CSRF_TRUSTED_ORIGINS=http://localhost:3000,https://yourdomain.com

🔒 Security Considerations

  • Never commit your .env file
  • Change the SECRET_KEY in production
  • Set DEBUG=False in production
  • Configure proper ALLOWED_HOSTS in production
  • Use proper SSL/TLS in production

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

📧 Contact

leen2233 - @leenrejepov

Project Link: https://github.com/leen2233/drf-project-template

About

DRF quickstart template to start new project easily

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages