Deploying Django Projects
With its admin panel, ORM, and rich ecosystem, Django is the web's "batteries-included" framework. Skyversal automatically runs your Django projects with Gunicorn following production best practices.
What you'll learn in this guide
- ✅ Required dependencies and file structure
- ✅ Static file management with WhiteNoise (collectstatic)
- ✅ Database migration commands (migrate)
- ✅ Gunicorn and production settings (ALLOWED_HOSTS)
1. Required Dependencies (requirements.txt)
To ensure your application runs smoothly in production, make sure your requirements.txt includes these essential dependencies:
Django's built-in python manage.py runserver is for local development only and should never be used in production. When Skyversal detects the gunicorn package, it starts your project with a multi-threaded production server.
2. Security and Environment Variables (settings.py)
Before pushing your code to GitHub, make your security settings dynamic in settings.py. Never hardcode secrets; add them as environment variables from the Skyversal panel (Settings > Environment Variables).
3. Static Files and WhiteNoise (Critical)
When DEBUG = False, Django stops serving CSS, JS, and images. To prevent static files from returning 404 errors, you need to use WhiteNoise.
Add WhiteNoise to the MIDDLEWARE list in settings.py. It must come right after SecurityMiddleware!
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
...
]
Skyversal automatically runs collectstatic during the build. You need to specify the target directory for collected files.
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
4. Database and Migrations
After deploying your project on Skyversal, you'll need to create your database tables.
- Go to the Skyversal panel and open your project's Deploy Logs / Run Commands tab.
- Type
python manage.py migratein the command field and execute it. - To create a superuser,
python manage.py createsuperuseris interactive. Instead, you can use a custom management command that reads from environment variables, or connect directly to your Managed Database using a database client (DBeaver, etc.).
Common Errors (Troubleshooting)
Fix: Your project root is missing requirements.txt or it doesn't include Django. Make sure the file is pushed to GitHub.
Fix: You're running with DEBUG=False without WhiteNoise. Add the WhiteNoise settings from Step 3 to your settings.py.
Fix: Your database tables don't exist. Run python manage.py migrate from the panel to create them.
Fix: Gunicorn couldn't start. There may be a syntax error in your code or the ALLOWED_HOSTS setting is missing. Check your deploy logs.
You're Ready! 🚀
After completing these settings, just push your code. Skyversal will have your site live with SSL via Gunicorn in seconds.