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
DEBUGoff, 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.
| Item | What production needs | Why it matters |
|---|---|---|
DEBUG | Set to False | Debug pages can show your settings and code to anyone |
SECRET_KEY | Read from an environment variable | Anyone with your key can forge sessions and tokens |
ALLOWED_HOSTS | Your real domain names | Django refuses requests for hosts it doesn't recognise |
| Database | A managed database service, often PostgreSQL, connected with dj-database-url | SQLite on a server is fragile, and your data needs backups |
| Web server | A production server such as Gunicorn | The development server isn't built for real traffic |
| Static files | Collected with collectstatic and served properly | Django stops serving them once DEBUG is off |
| Media files | Stored somewhere permanent | Uploads saved inside the app can vanish on redeploy |
| Migrations | Run each time you release | Your database needs to match your models |
| Background tasks | Celery workers with Redis | Emails 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.

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 item | Shared hosting | VPS | Managed app platform |
|---|---|---|---|
| Python and a web server | Limited | You set them up | Handled for you |
| Environment variables for secrets | Sometimes | You configure them | Built in |
| PostgreSQL | Rarely | You install it | Often included |
| Static files | Depends on the host | You configure the web server | WhiteNoise, or the platform |
| Media uploads | Saved on the server | Saved on the server | Object storage |
| Celery and Redis | Rarely | You install them | Often included |
| Who maintains it | The host, within limits | You | The 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:
- Does it support a current Python version and install your requirements automatically?
- Can you store settings as environment variables, so your
SECRET_KEYand database password never touch your repository? - Is PostgreSQL included, or is it a separate database service to buy and connect?
- Can you run commands like
collectstaticand migrations as part of each release? - Can it run Celery workers and Redis beside your Django project?
- Where do media uploads go? If the answer is "inside the app", check what happens on redeploy.
- 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:
- 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.
- Connect your code. Link your GitHub repository or upload a .zip, then add your
SECRET_KEY,ALLOWED_HOSTS, and other settings as environment variables. - Push. HCode detects Python, installs your dependencies, builds your Django project, and serves it over HTTPS.
| Checklist item | On HCode |
|---|---|
| Python and dependencies | Detected and installed for you; bring a Dockerfile if you need system libraries for images or PDFs |
| Secrets and settings | Stored encrypted in the panel; settings.py reads them at runtime |
| PostgreSQL | Managed and included, backed up daily; connect it with dj-database-url |
| Static files | Served by your app with WhiteNoise; add collectstatic to your build settings |
| Migrations | Run them in your start command, because the database is reachable once the app starts, not during the build |
| Celery and Redis | Celery runs as a background worker beside your app, with managed Redis as the broker |
| Media uploads | Files saved inside the app don't survive a redeploy, so connect S3-compatible object storage |
| Releases | New releases go live without downtime; a failed build never replaces the live site, and rollbacks take one click |
| Domain and SSL | A 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.
