A Django 6.0 project configured for deployment on Railway with PostgreSQL, Gunicorn, and WhiteNoise.
- Python 3.12
- Django 6.0
- PostgreSQL (via
dj-database-url) - Gunicorn (WSGI server)
- WhiteNoise (static files)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # then edit with your values
python manage.py migrate
python manage.py runserver| Variable | Description | Example |
|---|---|---|
SECRET_KEY |
Django secret key | (generate a random key) |
DEBUG |
Enable debug mode | True or False |
ALLOWED_HOSTS |
Comma-separated hostnames | localhost,127.0.0.1 |
CSRF_TRUSTED_ORIGINS |
Comma-separated origins | https://your-app.up.railway.app |
DATABASE_URL |
Database connection string | postgresql://user:pass@host:5432/db |
- Push to a GitHub repo
- Connect the repo in Railway
- Add a PostgreSQL service and link it to the app
- Set environment variables in Railway's dashboard
- Railway auto-detects the
Procfileandrailway.json