Skip to main content
A Django project runs on Sevalla as an application built from your Git repository: Ingot installs its dependencies, collects its static files during the build and starts it with Gunicorn in the web process, WhiteNoise serves the static files, and a job runs the migrations before each deployment. Its data lives in a Sevalla PostgreSQL database that the application reaches over an internal connection.

At a glance

Environment variables

The internal connection also adds DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD, which the project doesn’t read.

Before you begin

  • A Sevalla company with a payment method, and a GitHub, GitLab or Bitbucket account for the repository. See Git providers.
  • Python 3.12 or later on your computer. Django 6.1 needs Python 3.12 or later.

Create the project

Create a virtual environment, install Django and the packages the project needs in production, and start a project named storefront:
Keep local files out of the repository:
.gitignore
For local development, put development values in .env. Sevalla doesn’t use this file: you set the production values as environment variables.
.env

Prepare the project for Sevalla

Read settings from environment variables

In storefront/settings.py, replace everything from from pathlib import Path to ALLOWED_HOSTS = [] so that the secret key, debug mode and hosts come from the environment:
storefront/settings.py
Then replace the DATABASES setting:
storefront/settings.py
  • DEBUG is False unless you set it.
  • DB_URL is the variable Sevalla adds when you connect the database. django-environ accepts the postgres:// URL that Sevalla generates. Without DB_URL, the project uses SQLite locally.
  • Django sees HTTPS requests as secure without SECURE_PROXY_SSL_HEADER: Ingot’s image trusts the X-Forwarded-Proto header that Sevalla’s proxy sets (see proxy headers). Form posts on the application’s own domains, such as the admin’s sign-in, pass Django’s CSRF check without CSRF_TRUSTED_ORIGINS.

Serve static files with WhiteNoise

Add WhiteNoise right after SecurityMiddleware:
storefront/settings.py
Then replace STATIC_URL with where Django collects static files and how it stores them:
storefront/settings.py
Because the settings set STATIC_ROOT, Ingot runs python manage.py collectstatic --noinput during the build, so the files are part of the image. WhiteNoise compresses them and gives them hashed names, so browsers and the Sevalla CDN can cache them for a long time.

Pin the Python version

Ingot builds on Python 3.14, its default line, unless the project sets a version. Django 6.1 supports Python 3.12 to 3.14. Pin 3.14 in .python-version, so the build doesn’t change when a new Ingot release moves its default line:
.python-version
See Pin the Python version.

List the dependencies

Ingot installs requirements.txt with pip, into a virtual environment at /app/.venv that’s on the PATH:

How Ingot builds and starts the project

The project needs no build or start configuration. Ingot finds manage.py and Django in requirements.txt, and then:
  • Installs the dependencies and runs collectstatic. If SECRET_KEY isn’t available during the build, Ingot sets a placeholder for collectstatic only, which doesn’t use it.
  • Starts the web process with gunicorn -c /etc/ingot/gunicorn.conf.py storefront.wsgi:application. Gunicorn listens on the port in the PORT environment variable, which Sevalla sets to the web process’s port (8080 by default).
  • Doesn’t run migrations. A job runs them once per deployment, before the new version starts.
Gunicorn runs 1 worker process, and Ingot’s Gunicorn settings give it 4 threads, which fits the smallest size, H1 (0.3 GB of memory). On a larger size, set the WEB_CONCURRENCY environment variable to the number of worker processes, for example 2: Gunicorn reads it at start. To run another server or other options, see Set the start command. Commit everything and push it to your Git provider:

Deploy to Sevalla

These steps build with Ingot. To build from your own Dockerfile instead, see Deploy with a Dockerfile.
1

Create the database

In the sidebar, click Databases, then click Create database. Under Database, choose PostgreSQL and the newest version. Enter orders-db as the Display name, choose a Data center and a Size, then click Create database. See Create a database for every field.
2

Create the application

In the sidebar, click Applications, then click Create > Application. Under Source, click Private repository, then choose the Git provider, the Repository and the Branch. Under Location, choose the same Data center as the database. Keep the Size at H1 or choose a larger one, then click Create application. The application opens on its Overview tab with the status Not deployed yet: creating an application doesn’t deploy it.
3

Connect the database

Click the Networking tab. Under Connected services, click Add internal connection. Choose orders-db as the Service, turn on Add environment variables to the application, and click Add internal connection. Sevalla adds DB_URL and the other connection variables to the application. See Connect an application.
4

Add the environment variables

Click the Environment variables tab, then click Add environment variables. Add these variables and click Add environment variables:Don’t set DEBUG: it defaults to False.
5

Create the migration job

Click the Processes tab, then click Create process. Choose Job, enter Migrate as the Name and python manage.py migrate --noinput as the Custom start command. Keep the Start policy at Before deployment and the Resource at H1, then click Create process.
6

Deploy

Click the Overview tab, then click Deploy now under Recent deployments. Check the Branch and click Deploy.
7

Turn on auto-deploy

To deploy every push to the branch automatically, click the Settings tab, then click Update auto-deploy in the Auto-deploy section. Turn on Auto-deploy and click Update auto-deploy. See Deployments.
The Create process sheet with Job selected, the Name and Custom start command fields, the Start policy set to Before deployment, and the H1 resourceThe Create process sheet with Job selected, the Name and Custom start command fields, the Start policy set to Before deployment, and the H1 resource

Verify the deployment

  1. On the Deployments tab, wait for the deployment’s status to change to Deployed. The application’s status next to its name changes to Running. Open the deployment to read its build log. Ingot’s build plan comes first:
    Build log
    Later, the build log shows collectstatic copying the static files to /app/staticfiles, and, during the rollout, Migrate has been successful. If the job fails, the deployment fails and nothing changes for visitors. See Read the build plan. With the API, Get deployment (getDeploymentV3) returns the status, success for Deployed, and Get application deployment logs (getApplicationDeploymentLogsV3) returns the build log, which search filters. APP_ID and DEPLOYMENT_ID come from Deploy with the API:
  2. Click the domain under the application’s name, then add /admin/ to the address. Django’s admin sign-in page opens with its styles, which shows that WhiteNoise serves the static files. The site root returns 404 until you add your own URLs, because the welcome page only shows with DEBUG on. From a shell, with your application’s domain:
  3. To sign in to the admin, create a superuser. Click the Web terminal tab, and in the shell that opens in the Web process, run:
    Ingot puts the virtual environment’s bin folder on the PATH, so python is the project’s Python with its packages. See Web terminal. createsuperuser asks for a password, so it needs the terminal. A script or an AI agent can run a command that doesn’t ask anything with Run a command in a process (execProcessCommandV3). migrate --check exits with 0 when every migration has run:
    CLI: sevalla apps processes exec "$WEB_ID" --app-id "$APP_ID" -- python manage.py migrate --check. MCP: sevalla_api_update with execProcessCommandV3.

Deploy with a Dockerfile

Ingot needs no Dockerfile. Write your own when you want full control of the image: the base image, the system packages and every layer. Add a Dockerfile and a .dockerignore to the root of the repository:
Dockerfile
.dockerignore
Commit and push both files. Ingot doesn’t use the Dockerfile, so you can keep it in a repository that builds with Ingot, but it adds the .dockerignore patterns to its own: its build plan shows an Ignored row with 8 patterns from .dockerignore. Then switch the application to the Dockerfile build strategy:
1

Choose the Dockerfile build strategy

On the application’s Settings tab, in the Build strategy section, click Update build strategy. Click Dockerfile, keep the Dockerfile path Dockerfile and the Docker context ., then click Update build strategy.
2

Deploy

Click the Overview tab, then click Deploy now under Recent deployments. Check the Branch and click Deploy.
The Update build strategy sheet with Dockerfile selected, the Dockerfile path, the Docker context and the Docker registry credentialThe Update build strategy sheet with Dockerfile selected, the Dockerfile path, the Docker context and the Docker registry credential
The build log shows 📦 Building and pushing docker image using Dockerfile... where Ingot’s build plan was, then Migrate has been successful: the job runs python manage.py migrate --noinput in the new image. The admin at /admin/ opens with its styles, signing in works as before, and the deployment’s Dockerfile tab shows your Dockerfile. See Dockerfile.

Deploy changes

With Auto-deploy on, every push to the branch starts a deployment; otherwise, click Deploy now for each change. Each deployment builds the image, runs the Migrate job, then replaces the web process’s instances. For a schema change, run python manage.py makemigrations locally and commit the new migration with the code. When you add a package, run pip freeze > requirements.txt again and commit it. See Deployments.

Add a custom domain

Add the domain on the application’s Domains tab, then add it to ALLOWED_HOSTS, for example storefront-x7k2m.sevalla.app,shop.example.com, and deploy. Custom domains need a web process larger than H1.

Troubleshoot the deployment

For more causes, see Troubleshoot Ingot builds and Troubleshoot builds and deployments. To add uploads, caching or background tasks, see the Django guides.

Deploy with the API

This sequence creates the same database, application, job and deployment as Deploy to Sevalla, with the Sevalla API, and builds with Ingot. A script or an AI agent runs it as is. Run the steps in order in one shell: later steps use the IDs that earlier steps save in shell variables. Each step names the CLI command and the Sevalla MCP server tool that do the same. You need:
  • An API key with the Company developer role, in SEVALLA_API_KEY.
  • The repository pushed as in Prepare the project for Sevalla, and a GitHub account with access to it connected to Sevalla. The API has no call that reports the connection: without access, the step that creates the application fails with 400 and Cannot access repository https://github.com/acme/storefront: Repository not found or you don't have access., followed by where to connect a Git account (My account in the dashboard) and, for GitHub, to give Sevalla’s GitHub App access to the repository.
  • curl, jq, openssl and python3.
1

Choose the location

List clusters (listClustersV3) returns every location with its display_name and its region ID in location. Save one by region ID (see Locations):
CLI: sevalla resources clusters. MCP: get_platform_options.
2

Look up the process size

List process resource types (listProcessResourceTypesV3) returns the sizes by name. Save H1:
CLI: sevalla resources process-types. MCP: get_platform_options.
3

Look up the database size

List database resource types (listDatabaseResourceTypesV3). Save the smallest size, DB1:
CLI: sevalla resources db-types. MCP: get_platform_options.
4

Look up the PostgreSQL version

List database versions (listDatabaseVersionsV3) returns the versions the location offers, oldest first. Save the newest:
CLI: sevalla resources db-versions --cluster "$CLUSTER_ID" --type postgresql. MCP: not needed, create_database takes the newest version by default.
5

Create the database

Create database (createDatabaseV3) starts creating the database and returns its ID. You choose the password, and the API never returns it, so keep it for the connection URL:
CLI: sevalla databases create --name orders-db --type postgresql --db-version "$PG_VERSION" --cluster "$CLUSTER_ID" --resource-type "$DB1_ID" --db-name storefront --db-user storefront --db-password "$DB_PASSWORD". MCP: create_database, which generates a password it never returns. With connect_to_application_id and env_var_name: "DB_URL", once the application exists, it also does the internal connection and adds DB_URL as a postgresql:// URL, which django-environ accepts too.
6

Wait for the database

Get database (getDatabaseV3) shows status ready when the database is up, with its internal hostname and port:
CLI: sevalla databases get "$DB_ID". MCP: get_database.
7

Create the application

Create application (createApplicationV3) creates the application with a web process, and doesn’t deploy it:
CLI: sevalla apps create --name storefront --cluster "$CLUSTER_ID" --source privateGit --git-type github --repository "$REPO" --branch "$BRANCH". MCP: create_application with deploy: false.
8

Find the web process

List processes (listProcessesV3) returns the web process the application came with:
CLI: sevalla apps processes list --app-id "$APP_ID". MCP: get_application.
9

Size the web process

The API creates the web process at S1, not the dashboard’s H1. Update process (updateProcessV3) sets H1:
It prints h1. CLI: sevalla apps processes update "$WEB_ID" --app-id "$APP_ID" --resource-type "$H1_ID". MCP: scale_process with size_id and apply_now: false.
10

Connect the database

Create internal connection (createApplicationInternalConnectionV3):
Unlike the dashboard, the API adds no environment variables; the next steps add them. CLI: sevalla apps internal-connections create "$APP_ID" --target-id "$DB_ID" --target-type database. MCP: sevalla_api_create with createApplicationInternalConnectionV3 and the same body.
11

Get the domain

List application domains (listApplicationDomainsV3) returns the application’s sevalla.app domain, which ALLOWED_HOSTS needs:
CLI: sevalla apps domains list --app-id "$APP_ID". MCP: get_application.
12

Add the environment variables

Create environment variable (createEnvironmentVariableV3), once per variable. The DB_* variables have the names and format of the dashboard’s internal connection, available during build and runtime as it adds them. SECRET_KEY and ALLOWED_HOSTS are available during runtime only:
It prints each key as it’s added. CLI: sevalla apps env-vars create "$APP_ID" --key SECRET_KEY --value "$SECRET_KEY", once per variable; the CLI makes each variable available during build and runtime. MCP: set_environment_variables, with buildtime: false for SECRET_KEY and ALLOWED_HOSTS.
13

Create the migration job

Create process (createProcessV3) needs the size, a scaling_strategy and, for a job, the job_start_policy:
CLI: sevalla apps processes create "$APP_ID" --name Migrate --type job --resource-type "$H1_ID" --command "python manage.py migrate --noinput" --job-start-policy beforeDeployment. MCP: sevalla_api_create with createProcessV3 and the same body.
14

Deploy

Trigger deployment (triggerDeploymentV3) deploys the latest commit of the branch:
CLI: sevalla apps deployments trigger "$APP_ID". MCP: trigger_deployment.
15

Wait for the deployment

Get deployment (getDeploymentV3) reports the status, which ends as success, failed, cancelled or skipped. The loop keeps polling through a failed request, for up to 30 minutes:
CLI: sevalla apps deployments get "$DEPLOYMENT_ID" --app-id "$APP_ID". MCP: get_deployment.
16

Turn on auto-deploy

Update application (updateApplicationV3):
It prints true. CLI: sevalla apps update "$APP_ID" --data '{"auto_deploy": true}'. MCP: sevalla_api_update with updateApplicationV3 and the same body.
Then run the checks in Verify the deployment, with APP_HOST in place of storefront-x7k2m.sevalla.app. To build with the Dockerfile instead, update the application with {"build_type": "dockerfile", "dockerfile_path": "Dockerfile", "docker_context": "."} before you deploy (CLI: sevalla apps update "$APP_ID" --data with the same body; its --build-type option leaves the Docker context unset).