Django is the most popular Python web framework, widely used in Uzbekistan's tech community for everything from university projects to production e-commerce sites. if.uz makes deploying Django as simple as pushing to GitHub.
Project Structure Requirements
Nixpacks detects Django automatically if you have a requirements.txt and a manage.py at your project root. No Dockerfile required.
my-django-project/
├── manage.py
├── requirements.txt
├── Procfile ← tells if.uz how to start the app
├── myapp/
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── ...Step 1 — requirements.txt
Include Django and gunicorn (the production WSGI server). Nixpacks installs everything in requirements.txt:
Django>=4.2
gunicorn>=21.2
psycopg2-binary>=2.9 # PostgreSQL adapter
dj-database-url>=2.0 # Parse DATABASE_URL string
whitenoise>=6.6 # Serve static files without a separate web server
python-decouple>=3.8 # Read .env variablesStep 2 — Procfile
web: gunicorn myapp.wsgi --workers 2 --bind 0.0.0.0:$PORT --log-file -⚠️ Warning
Replace "myapp" with the name of your Django project (the folder containing wsgi.py). Use $PORT — if.uz injects the port at runtime.
Step 3 — Production Settings
Update your settings.py for production. The cleanest approach is to read everything from environment variables:
import os
import dj_database_url
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-key-change-me')
DEBUG = os.environ.get('DEBUG', 'False') == 'True'
ALLOWED_HOSTS = ['*'] # or list your specific domains
# Database — reads DATABASE_URL env var
DATABASES = {
'default': dj_database_url.config(
default='sqlite:///db.sqlite3',
conn_max_age=600,
)
}
# Static files — WhiteNoise serves them directly
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware', # ← add after SecurityMiddleware
...
]Step 4 — Deploy on if.uz
- 1Push your code to GitHub
- 2Sign in to if.uz and click "Deploy new app"
- 3Select your GitHub repo and branch
- 4Click Deploy — Nixpacks detects Python, installs requirements, and starts gunicorn
Step 5 — Add Environment Variables
In your dashboard, go to Environment Variables and add:
SECRET_KEY=your-long-random-secret-key-here
DEBUG=False
ALLOWED_HOSTS=yourapp-username.if.uz,yourdomain.uzStep 6 — Add Postgres from Marketplace
- 1Go to Marketplace → Deploy PostgreSQL
- 2Copy the internal connection URL from Connection Details
- 3Add it as DATABASE_URL in your environment variables
- 4Redeploy the app
- 5Run migrations: open the dashboard logs, or add a release command
💡 Tip
To run migrations on every deploy, add a release phase to your Procfile: "release: python manage.py migrate". Nixpacks/Procfile will run this before starting gunicorn.
# Procfile with automatic migrations
release: python manage.py migrate --noinput && python manage.py collectstatic --noinput
web: gunicorn myapp.wsgi --workers 2 --bind 0.0.0.0:$PORT --log-file -Common Issues
| Issue | Fix |
|---|---|
| DisallowedHost error | Add your if.uz subdomain to ALLOWED_HOSTS in settings.py or env var |
| Static files 404 | Make sure WhiteNoise is in MIDDLEWARE and STATIC_ROOT is set. Run collectstatic in release command. |
| psycopg2 install fails | Use psycopg2-binary in requirements.txt (not psycopg2) |
| Port binding error | Use $PORT in gunicorn --bind, not a hardcoded number |
Django on if.uz is a powerful combination: Python's best web framework on Uzbekistan's best hosting platform. No DevOps degree required.