developer-environment-setup

Django Starter Template

A professional Django REST API starter with PostgreSQL, CORS, and best practices.

Features

Getting Started

Prerequisites

Installation

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file
copy .env.example .env

# Update database settings in .env

# Run migrations
python manage.py migrate

# Create superuser
python manage.py createsuperuser

# Run development server
python manage.py runserver

Open http://localhost:8000/api/ in your browser.

API Endpoints

Environment Variables

Create a .env file:

SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1
DB_NAME=django_db
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432

Project Structure

django-starter/
├── django_starter/
│   ├── settings.py       # Django settings
│   ├── urls.py          # Main URL config
│   └── wsgi.py          # WSGI config
├── api/
│   ├── models.py        # Database models
│   ├── serializers.py   # DRF serializers
│   ├── views.py         # API views
│   └── urls.py          # API URLs
├── manage.py            # Django management
├── requirements.txt     # Dependencies
└── .env                 # Environment variables

Production Deployment

# Collect static files
python manage.py collectstatic --noinput

# Run with Gunicorn
gunicorn django_starter.wsgi:application --bind 0.0.0.0:8000

Learn More