• Django in South Africa
  • PostgreSQL included
  • First month free

How to Host a Django Website: What Changes in Production

Learn how to host a Django website: what changes in production, where static and media files should live, and what to look for when you choose a host.

You set DEBUG = False, refresh the page, and your carefully styled Django project now looks like it was built in 1998. No CSS, no images, just plain text on a white background. Welcome to production.

Django is famously friendly in development and famously strict once it goes live. That strictness is a good thing, but it means hosting a Django website takes more than finding a server that runs Python.

This guide explains how to host a Django website properly: what changes in production, where your static and media files should live, and what to look for when you choose a host.

If you're new to app hosting in general, our guide to web app hosting covers the basics first.

Key Takeaways: How to Host a Django Website

  • Django changes how it behaves in production. With DEBUG off, it stops serving static files and starts enforcing your security settings.
  • Static files need a plan. Collect them once, then serve them with WhiteNoise or a web server.
  • Media files need somewhere permanent. On most managed platforms, uploads saved inside the app disappear on redeploy, so they belong in object storage.
  • Look for a host that runs the whole stack: Python, PostgreSQL, Redis, and Celery workers, not just the web app.
  • HCode hosts Django websites in South Africa from R50 a month, with PostgreSQL included.

What Changes When Your Django Project Goes Live

When a Django project goes live, Django stops doing you favours and starts protecting your users.

In development, Django is relaxed. The built-in server reloads your code, serves your CSS, and shows detailed error pages with your settings on display. All of that is helpful on your laptop and dangerous on the internet.

In production, Django expects you to switch those conveniences off and replace them with the real thing.

A proper web server takes over from the development server, your secrets move into environment variables, and static files get served by something built for the job. Django even ships with its own deployment checklist, and running python manage.py check --deploy flags the settings you've missed.

The good news: you don't need to memorise Django's settings. You need to know what your Django web application needs in production, and whether your host provides it.

The Django Production Checklist

Here's what a Django project needs before it's ready for real visitors, in plain language.

ItemWhat production needsWhy it matters
DEBUGSet to FalseDebug pages can show your settings and code to anyone
SECRET_KEYRead from an environment variableAnyone with your key can forge sessions and tokens
ALLOWED_HOSTSYour real domain namesDjango refuses requests for hosts it doesn't recognise
DatabaseA managed database service, often PostgreSQL, connected with dj-database-urlSQLite on a server is fragile, and your data needs backups
Web serverA production server such as GunicornThe development server isn't built for real traffic
Static filesCollected with collectstatic and served properlyDjango stops serving them once DEBUG is off
Media filesStored somewhere permanentUploads saved inside the app can vanish on redeploy
MigrationsRun each time you releaseYour database needs to match your models
Background tasksCelery workers with RedisEmails and slow jobs shouldn't keep visitors waiting

None of this needs to be done by hand on the right host. But every item needs an answer, and the two that catch people out most are static and media files.

Static and Media Files: The Two That Catch Everyone

Static files are the files you ship with your project; media files are the ones your users upload. Django treats them differently in production, and so should your hosting.

Static Files: Your CSS, JavaScript, and Images

In development, Django serves static files for you. In production, it stops, which is why your styling disappears when DEBUG goes off. The fix has two parts: collect every static file into one folder with collectstatic, then serve that folder with something built for the job.

For most Django projects on a managed platform, that something is WhiteNoise, a small package that lets your app serve its own static files efficiently. In your Django settings, it comes down to a few lines:

STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "staticfiles"

MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "whitenoise.middleware.WhiteNoiseMiddleware",
    # ...the rest of your middleware
]

The same setup covers the Django admin, too. Its styling is collected and served alongside yours, so the admin looks right in production.

Comparison of Django static files and media files: static files are CSS, JavaScript, and images collected with collectstatic and served by WhiteNoise, rebuilt with every release; media files are user uploads stored in S3-compatible object storage, kept safe outside the app on redeploy.

Media Files: Everything Your Users Upload

Media files are a different story. Profile photos, documents, and anything else your users upload need to live somewhere permanent. On most managed platforms, files saved inside the app are temporary, so they disappear the next time the app redeploys or restarts.

The standard answer is S3-compatible object storage, connected to Django with a package such as django-storages. Your app keeps running on the platform, and uploads go straight to storage that a redeploy can't touch. It's a bit like keeping your important papers in a safe rather than in the pocket of a jacket you send to the dry cleaner every week.

Where to Host a Django App: Your Options

There are three realistic places to host a Django app, and they differ in how much of the checklist you handle yourself.

Shared hosting is built mainly for PHP websites. Some plans offer a Python app option, but running Celery workers, Redis, or a recent Python version can be difficult, and a Django project with background tasks usually outgrows it quickly.

A VPS runs anything, Django included. You set up the Python virtual environment, the web server, the database, static files, and Celery yourself, then keep them patched and backed up.

A managed app platform detects your Python project, builds it, and runs it. The better ones put the database, Redis, and workers right beside your app.

Checklist itemShared hostingVPSManaged app platform
Python and a web serverLimitedYou set them upHandled for you
Environment variables for secretsSometimesYou configure themBuilt in
PostgreSQLRarelyYou install itOften included
Static filesDepends on the hostYou configure the web serverWhiteNoise, or the platform
Media uploadsSaved on the serverSaved on the serverObject storage
Celery and RedisRarelyYou install themOften included
Who maintains itThe host, within limitsYouThe platform

What to Look for in the Best Hosting for Django

The best hosting for Django is the one that answers every item on the checklist without making you a full-time server admin. Hold any host up against these seven questions:

  1. Does it support a current Python version and install your requirements automatically?
  2. Can you store settings as environment variables, so your SECRET_KEY and database password never touch your repository?
  3. Is PostgreSQL included, or is it a separate database service to buy and connect?
  4. Can you run commands like collectstatic and migrations as part of each release?
  5. Can it run Celery workers and Redis beside your Django project?
  6. Where do media uploads go? If the answer is "inside the app", check what happens on redeploy.
  7. What happens when a release breaks? A failed build should never replace your live site, and rolling back should be quick.

For South African teams, two more questions belong on the list: where your app and data live, and whether you pay in rand or dollars.

How to Host a Django Website on HCode

HCode is HostAfrica's managed app platform, and it takes care of most of the Django checklist for you. Getting started takes three steps:

  1. Pick a plan. Choose one on the Django hosting page and order it in the HostAfrica client panel. Plans start at R50 a month, and code HCODEFREE2026 makes your first month free.
  2. Connect your code. Link your GitHub repository or upload a .zip, then add your SECRET_KEY, ALLOWED_HOSTS, and other settings as environment variables.
  3. Push. HCode detects Python, installs your dependencies, builds your Django project, and serves it over HTTPS.
Checklist itemOn HCode
Python and dependenciesDetected and installed for you; bring a Dockerfile if you need system libraries for images or PDFs
Secrets and settingsStored encrypted in the panel; settings.py reads them at runtime
PostgreSQLManaged and included, backed up daily; connect it with dj-database-url
Static filesServed by your app with WhiteNoise; add collectstatic to your build settings
MigrationsRun them in your start command, because the database is reachable once the app starts, not during the build
Celery and RedisCelery runs as a background worker beside your app, with managed Redis as the broker
Media uploadsFiles saved inside the app don't survive a redeploy, so connect S3-compatible object storage
ReleasesNew releases go live without downtime; a failed build never replaces the live site, and rollbacks take one click
Domain and SSLA free subdomain on the first deploy, then your own domain with automated SSL

Moving an existing Django project? Import your PostgreSQL data from a .sql file or pg_dump archive, and HCode backs up the database before the import replaces anything. Everything runs in South Africa, on one flat price in rand.

Prefer to Run It Yourself?

If you'd rather manage the Python version, Gunicorn, and every server setting yourself, a VPS gives you full control. Our step-by-step guide shows you how to deploy a Python app from GitHub to a VPS, with the same workflow for Django, Flask, and FastAPI, from the virtual environment through to Nginx and HTTPS.

FAQs: Hosting a Django Website

Where Should I Host a Django App?

On a host that runs Python and keeps PostgreSQL, Redis, and background workers close by. A managed app platform handles the server for you; a VPS gives you full control if you're happy to maintain it.

Can I Host a Django Project for Free?

Some providers offer free tiers, but they usually limit always-on workers, databases, or commercial use. HCode has no free tier, but code HCODEFREE2026 gives you your first month free.

How Do I Serve Static Files in Django Production?

Collect them into one folder with collectstatic, then serve that folder with WhiteNoise or a web server. Django stops serving static files itself once DEBUG is set to False.

Where Should Django Media Files Go in Production?

Somewhere permanent, outside the app. On most managed platforms, uploads saved inside the app disappear on redeploy, so connect S3-compatible object storage with a package such as django-storages.

Does Django Work With PostgreSQL?

Yes. PostgreSQL is one of Django's best-supported databases, and HCode includes managed PostgreSQL on every plan, so features from django.contrib.postgres work without a separate database service.

Can I Run Celery on HCode?

Yes. HCode runs Celery as a background worker beside your Django web app, with managed Redis as the broker.

Avatar for Ashwin S.

The Author

Ashwin S.

Ashwin is a content specialist at HostAfrica, where he's been crafting clear, authoritative copy since 2021. With a background in digital marketing and a passion for impactful storytelling, he turns complex ideas into trustworthy, engaging content. Ashwin writing helps our audience navigate web hosting and cloud solutions with confidence.

Your Django Project, Production-Ready

Push your code, and HCode builds your Django project, runs your Celery workers, and keeps PostgreSQL and Redis right beside it. One flat price in rand.

Your first month is on us with codeHCODEFREE2026