Skip to main content
Guide for deploying Django applications written in Python.

Prerequisites

Django VersionSupported Python Version
Django 3.13.6, 3.7, 3.8, 3.9
Django 3.23.6, 3.7, 3.8, 3.9, 3.10
Django 4.03.8, 3.9, 3.10
Django 4.13.8, 3.9, 3.10, 3.11
Django 4.23.8, 3.9, 3.10, 3.11, 3.12
Django 5.03.10, 3.11, 3.12
Django 5.13.10, 3.11, 3.12
Ensure that the Python version specified in your project configuration files (e.g., requirements.txt) matches the version selected during deployment. A mismatch may cause build and runtime errors.

Select Template and Repository

On the dashboard, click or ⌘ + K to open the deployment modal and select the Python template. Then choose a GitHub repository from the dropdown or input a Git repository URL in the Git URL tab.
For Django, ensure that ALLOWED_HOSTS and CSRF_TRUSTED_ORIGINS are correctly set in settings.py for pages to load properly.

Deployment Settings

Apply the following settings to ensure your service runs seamlessly.
  • Version
  • Environment Variables
  • Port Number: 8000 (default)
  • Start Command: python3 manage.py runserver 0:8000 (default)
  • Health Check: Endpoint for container status verification
  • Build Variables: Variables to include during container image builds
  • Embedded Node.js: Node.js version required for builds within the project
  • Install Command: Python package installation command
  • Pre Start Command: Commands to run before the Start Command
  • Update strategy
    • Rolling Update: Deploy new version incrementally while maintaining service availability. Requires sufficient node resources
    • Recreate: Stop all instances before deploying new version. Results in downtime
Set environment variables and Pre Start Command as follows to create a Super User:
    [Environment Variables]
    DJANGO_SUPERUSER_USERNAME - Django superuser username
    DJANGO_SUPERUSER_PASSWORD - Django superuser password
    DJANGO_SUPERUSER_EMAIL    - Django superuser email

    [Pre Start Command]
    python3 manage.py makemigrations && python3 manage.py migrate && python3 manage.py createsuperuser --noinput

Set Resources and Deploy

  • Resource Type: Select between On-demand or Spot instance types
  • CPU: Maximum vCPU resource for the service. Minimum vCPU means 0.1 vCPU
  • Memory: Maximum memory size your service can use
  • Replica: Number of service replicas for high availability and load balancing
  • Deploy: Click Deploy
Once deployment is complete, you can access the web page via the preview domain or send requests using an API tool.
If deployment fails due to resource limitations, see the Space and Resource Management page to add resources to your space.

Django Docs
I