Django Cloudflare R2 Integration
A Django web application that integrates Cloudflare R2 as a cost-effective, S3-compatible storage backend for static and media files.
- Status
- Finished and delivered. It does what it set out to do and no more work is planned.
- Kind
- Web Development
- Started
- Sep 2025

About it
The problem
Serving static and media files from S3-style storage is standard for Django in production, but egress fees grow with traffic, and setting up an alternative correctly is poorly documented.
The approach
I built a reference Django project that uses Cloudflare R2 through its S3-compatible API, with separate storage backends for static files and user uploads on top of django-storages and boto3.
- Dedicated storage classes for static assets and media, configured through environment variables with python-decouple.
- Examples of FileField and ImageField uploads served from R2 through Cloudflare's network.
- A production checklist covering buckets, API token permissions, CORS, bucket policy and collectstatic.
The result
The project is a ready-to-copy reference that lets Django developers cut storage costs and serve files from Cloudflare's edge without leaving Django's familiar storage API.
What it does5
Cloudflare R2 Storage Integration
Environment-Based Configuration
Custom Storage Classes
S3-Compatible Interface
Production-Ready Setup
More work

Rone Arena API
A public FastAPI for Mobile Legends hero data, analytics and player tools, with a web playground and SDKs.

BeliMadu.com
An online honey shop on Next.js 16 and Cloudflare Workers, with a WhatsApp-checkout cart and a Vitest suite.

ridwaanhall.com
This site: a portfolio and blog on Next.js 16 with an admin, Markdown versions of every page and a CV generated from the About page.
Comments0
Signed-in readers can comment.