A professional Django REST API starter with PostgreSQL, CORS, and best practices.
# 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.
GET /api/ - API rootGET /api/items/ - List all itemsPOST /api/items/ - Create new itemGET /api/items/{id}/ - Get specific itemPUT /api/items/{id}/ - Update itemDELETE /api/items/{id}/ - Delete itemGET /admin/ - Django admin panelCreate 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
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
# Collect static files
python manage.py collectstatic --noinput
# Run with Gunicorn
gunicorn django_starter.wsgi:application --bind 0.0.0.0:8000