Deploy Guide · Python

Deploy a Django App

Ship your Django project to production with a single command.

Overview

Django is Python's batteries-included web framework for building robust web applications and REST APIs. Getting Django from local to production traditionally requires configuring Gunicorn, nginx, SSL, and a server. Kubeletto collapses all of that into one command.

Prerequisites

  • A Django project with requirements.txt or pyproject.toml
  • ALLOWED_HOSTS and DATABASE_URL configured via environment variables
  • A Kubeletto account

Step-by-Step Guide

Deploying Django to Kubeletto is done by configuring a Dockerfile, connecting your GitHub repository, and setting environment variables. Follow this step-by-step checklist to deploy your code:

  1. 1

    Write a production Dockerfile

    Use Gunicorn as your WSGI server inside the container. Kubeletto handles SSL and load balancing externally.

    dockerfile
    FROM python:3.12-slim
    WORKDIR /app
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt gunicorn
    COPY . .
    RUN python manage.py collectstatic --noinput
    EXPOSE 8000
    CMD ["gunicorn", "myproject.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "2"]
  2. 2

    Configure Django for containers

    Read settings from environment variables to keep secrets out of source code.

    python
    # settings.py
    import os
    SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
    ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',')
    DATABASES = {'default': env.db('DATABASE_URL')}
    DEBUG = os.environ.get('DEBUG', 'False') == 'True'
  3. 3

    Deploy via CLI or GitHub

    Push to GitHub and connect the repo in Kubeletto, or deploy directly from the CLI.

    bash
    kubeletto deploy --source github --repo your-org/django-app --branch main
  4. 4

    Set required environment variables

    Add all runtime configuration before your first deploy.

    bash
    kubeletto env set DJANGO_SECRET_KEY=your-secret-key --app django-app
    kubeletto env set DATABASE_URL=postgres://user:pass@host/db --app django-app
    kubeletto env set ALLOWED_HOSTS=django-app.kubeletto.app --app django-app

Sample Environment Variables

To configure your Django application, set these key-value pairs in the environment variables tab of the Kubeletto console or CLI. Ensure production secrets are flagged as write-only:

.env
DJANGO_SECRET_KEY=your-50-char-secret
DATABASE_URL=postgres://user:pass@host:5432/dbname
ALLOWED_HOSTS=django-app.kubeletto.app
DEBUG=False
REDIS_URL=redis://...
AWS_S3_BUCKET=your-bucket

Related Kubeletto Features

Kubeletto offers automatic SSL certificate provisioning, zero-downtime rollbacks, and scale-to-zero autoscaling for Django container workloads:

PaaS Platform Comparisons

See how Kubeletto compares directly against other cloud platforms and PaaS providers when deploying Python workloads:

Frequently Asked Questions

Find direct answers to common questions about hosting, building, scaling, and managing Django containerized apps on Kubeletto:

How do I run Django migrations on Kubeletto?

Add a migration step to your Docker entrypoint script: run `python manage.py migrate` before starting Gunicorn. This ensures migrations run on every new deployment revision.

Can I serve Django static files from Kubeletto?

For small projects, yes — use WhiteNoise middleware. For production scale, serve static assets from an external object storage bucket or CDN and configure STATIC_URL accordingly.

What WSGI/ASGI server should I use?

Gunicorn is recommended for WSGI apps. For async Django (channels or ASGI), use uvicorn or daphne and adjust your CMD accordingly.

Deploy your Django app today

Free during our active beta. No credit card required.

Start Deploying Free