Topic · Files & assets

Media & object storage for Django in production

User uploads: where they are stored, how they are served, and how to keep them safe and persistent.

uploads belong outside the serverUploadvalidatedDjangostorage APIS3 / R2private bucketPublicCDN URLPrivatesigned URLMedia survives redeploys and scales across servers only off the local disk

Media files are what users upload. They must survive every release and every server replacement, which usually means object storage such as S3 or R2 instead of the local disk.

The guides cover storage setup, private files and signed URLs, direct uploads, backups, and the permission and access errors that uploads run into.

15Set it up
4Run it well
3Check it
12Fix it

Set it up

Guides that take this from nothing to running in production.

  • How to Store Django Media Files on Amazon S3

    Local disk storage for Django media files works in development, but it breaks quickly in production.

  • Store Django Media Files on Cloudflare R2

    Store Django uploads on Cloudflare R2 with django-storages: scoped API tokens, STORAGES settings, custom domains, signed URLs, and migration.

  • Serve Private Django Media Files with Nginx X-Accel-Redirect

    Serve permission-checked Django downloads efficiently: Django authorises the request and returns X-Accel-Redirect, and an internal Nginx location streams the file without tying up workers.

  • Upload Files Directly to S3 from Django with Presigned URLs

    Let browsers upload large files straight to S3 with presigned POST policies: size and type limits, bucket CORS, server-side confirmation, FileField wiring, and cleanup of abandoned uploads.

  • Store Django Media Files on Google Cloud Storage

    Store Django user uploads on Google Cloud Storage with django-storages: create a bucket with uniform access, authenticate with Workload Identity or the runtime service account, serve private files with signed URLs, and set CORS and lifecycle rules.

  • Store Django Media Files on Azure Blob Storage

    Store Django uploads in Azure Blob Storage with django-storages: create a storage account and private container, authenticate with managed identity instead of account keys, serve files with SAS URLs, and add Azure CDN or Front Door for public assets.

  • Store Django Media Files on DigitalOcean Spaces

    Store Django uploads on DigitalOcean Spaces with django-storages’ S3 backend: set the regional endpoint, create scoped access keys, choose private files with presigned URLs or public files behind the Spaces CDN, and configure CORS.

  • Store Django Media Files on Backblaze B2

    Store Django uploads on Backblaze B2 through its S3-compatible API: create a bucket and application key, configure django-storages with the B2 endpoint, serve private files with presigned URLs, and put public files behind Cloudflare.

  • Self-Host Django Media Storage With MinIO

    Run MinIO as self-hosted S3-compatible storage for Django uploads: deploy it with Docker Compose or systemd, create a bucket and scoped user, configure django-storages, put MinIO behind Nginx with TLS, and back it up.

  • Store and Transform Django Media With Cloudinary

    Use Cloudinary for Django media uploads: configure django-cloudinary-storage or the Cloudinary SDK, upload user images and video, generate resized and optimized URLs on the fly, sign uploads from the browser, and keep secrets and costs under control.

  • Store Django Media on Hetzner Object Storage

    Use Hetzner Object Storage for Django media and static files with django-storages: create a bucket and S3 credentials, set the regional endpoint and addressing style, choose public or private access with presigned URLs, configure CORS, and keep costs low next to Hetzner Cloud servers.

  • Store Django Media on Wasabi Hot Cloud Storage

    Use Wasabi S3-compatible storage for Django media and backups with django-storages: set the regional endpoint, create a restricted policy, serve files with presigned URLs or a CDN, and understand minimum storage duration and egress terms.

  • Django Static vs Media Files in Production

    Many Django deployments break because static files and media files are treated as the same thing.

  • Deploy Wagtail CMS to Production

    Deploy a Wagtail site to production: Sites and WAGTAILADMIN_BASE_URL, image renditions and media storage, scheduled publishing, search indexing, document serving, and caching.

  • Serve Django Static and Media Files Through Bunny CDN

    Put Bunny CDN in front of a Django site: create a pull zone for WhiteNoise static files or an object storage origin, use hashed file names with long cache headers, serve media from Bunny Storage with django-storages, and purge or sign URLs when needed.

Run it well

Tuning, reliability, and operations once it works.

  • Serve Optimised Images and Thumbnails From Django

    Serve fast, right-sized images from a Django app: generate thumbnails in background tasks, use WebP and AVIF, responsive srcset, CDN or image service resizing, cache headers for media, and avoid resizing images inside web requests.

  • Handle Large and Resumable File Uploads in Django

    Accept large uploads in Django without timeouts or memory spikes: upload directly to S3 with multipart presigned URLs, use the tus resumable protocol, tune Nginx and Django upload limits, process files in Celery, and validate files after upload.

  • Back Up Django Media Files

    Back up Django uploads reliably: MEDIA_ROOT with restic, S3 versioning and replication, consistency with database backups, retention, and restores.

  • Speed Up Django collectstatic to S3

    Make collectstatic to S3 or other object storage fast: skip unchanged files, use storage backends that compare hashes, collect locally then sync with the AWS CLI, skip post-processing where safe, and run it once per release in CI instead of on every server.

Check it

Review lists to run before launch or after a change.

  • Django File Upload Security Checklist

    Secure user uploads in Django production: size limits at every layer, content-based type checks, image re-encoding, safe file names, private storage, serving user content safely, scanning, and quotas.

  • Wagtail Production Checklist

    A production checklist for Wagtail CMS sites: WAGTAILADMIN_BASE_URL and Sites, image renditions and storage, search backend, cache invalidation and frontend caching, admin security, scheduled publishing, backups of media, and upgrade routine.

  • Django Media Files Production Checklist

    A production checklist for Django user uploads: object storage instead of local disk, upload limits and validation, private versus public files, unique names, image processing in workers, CDN delivery, backups and versioning, and cleanup of orphaned files.

Fix it

Errors and symptoms, each traced to a cause and a fix.

Related topics