Skip to main content

Deploy Django on Hostim.dev

This guide shows how to deploy a Django app on Hostim.dev from a Git repository.

Quick start: Use the "Django Demo" template to skip the setup.

πŸ‘‰ Open the Console Click "+ New Project", pick Django Demo, and you're good to go.

Want to customize or start fresh? This guide walks you through the manual setup.


0. Create a Project​

Start by creating a new project:

  1. Open your Hostim.dev dashboard
  2. Click Create Project
  3. Pick one:
    • Scratch – start fresh
    • Template – use Django Demo for a prebuilt setup
    • Docker Compose – paste your own setup
  4. Choose Scratch for this guide
  5. Name it something like django-demo and hit Create Project

1. Use the Example Django App​

We're using this example Django app:

πŸ”— https://github.com/hostimdev/demo-django

No need to clone it unless you're running locally. If so, follow its README for local setup.

🐳 The repo already has a working Dockerfile and docker-compose.yml


2. Deploy on Hostim.dev​

⚠️ Set things up in this order: Volume β†’ Database β†’ Redis β†’ App. This makes sure all pieces are connected when the app starts.


2.1. Create a Volume for Media​

  1. In your dashboard, click Create Service β†’ New Volume
  2. Name it media-data (or anything you like)
  3. Pick a plan
  4. Click Create Volume

2.2. Add a MySQL Database​

  1. Click Create Service β†’ New MySQL
  2. Name it db
  3. Pick a plan
  4. Click Create MySQL

2.3. Add a Redis Instance​

  1. Click Create Service β†’ New Redis
  2. Name it redis
  3. Pick a plan
  4. Click Create Redis

2.4. Create the Django App​

  1. Click Create Service β†’ New App
  2. Choose Git for deployment type
  3. Enter: https://github.com/hostimdev/demo-django
  4. Set the branch to main
  5. Leave Dockerfile path as Dockerfile
  6. Choose your plan and replicas
  7. Under Volume Mounts, click Attach Volume
    • Pick media-data
    • Mount path: /app/media
  8. Enable HTTP Service
  9. Set HTTP Port to 8000
  10. Make the app public (or not)
  11. Click Create App

2.5. Set Up Environment Variables​

  1. Go to your app > Envs tab
  2. Add these variables:
DEBUG=1
SECRET_KEY=automatically_generated_32_char_key
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]
REDIS_HOST=$(REDIS_REDIS_HOST)
REDIS_PORT=$(REDIS_REDIS_PORT)
MYSQL_DATABASE=$(DB_MYSQL_DATABASE)
MYSQL_USER=$(DB_MYSQL_USER)
MYSQL_PASSWORD=$(DB_MYSQL_PASSWORD)
MYSQL_HOST=$(DB_MYSQL_HOST)
MYSQL_PORT=$(DB_MYSQL_PORT)
VariableWhat it does
DEBUGEnables debug mode for dev
SECRET_KEYAutomatically generated
DJANGO_ALLOWED_HOSTSWhitelisted hosts
MYSQL_*Filled from the MySQL service
REDIS_*Comes from the Redis service

Click Save Changes when you're done.


βœ… Next Steps​