django-redis
Full featured redis cache backend for Django.
What it is and what it does
django-redis is a production-ready Redis cache and session backend for Django that replaces Django's default cache framework with Redis storage. It uses redis-py's native URL notation for connection strings, supporting TCP sockets, SSL-wrapped connections, and Unix domain sockets. The package handles serialization via pickle by default, offers pluggable compression (zlib, lzma, lz4, zstandard, gzip), and can emulate memcached exception behavior by ignoring Redis connection failures.
Typically used to improve Django application performance by offloading cache and session storage to Redis, it integrates directly into Django's CACHES and SESSION_ENGINE settings. The package supports Redis ACLs, primary/secondary failover in the default client, infinite timeouts, and raw access to the underlying redis connection pool for advanced use cases. It has been used in production across multiple projects and maintains a comprehensive test suite.
Use it for:
- Replace Django's default in-memory cache with persistent Redis storage for multi-process deployments.
- Store Django sessions in Redis for horizontal scaling across multiple application servers.
- Enable cache compression to reduce memory usage on large cached objects.
- Configure Redis failover and primary/secondary support for high-availability caching.
- Use Unix domain sockets to cache locally without network overhead.
- Emulate memcached behavior by ignoring Redis downtime to prevent application crashes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Redis cache and session backend for Django, supporting native redis-py URL connection strings, pluggable serializers and parsers, and optional compression.
Yes. django-redis is actively maintained, production-proven, has no known vulnerabilities, low install friction, and a permissive license. It is the standard choice for Redis caching in Django projects that need persistence, scalability, or session sharing across servers. Install if you are using Django 5.2+ and have a Redis server available.
Install
django-redis on PyPI
pip
pip install django-redisuv
uv add django-redispoetry
poetry add django-redisInstalling django-redis
Before you install
Low install friction with a pure Python wheel. Actively maintained (last commit 2026-08-10) with production use across multiple projects. Requires Django 5.2+, redis 4.0.2+, and Python 3.10+.
License in practice
BSD-3-Clause permissive license allows commercial and private use with minimal restrictions; attribution required.
Quickstart
pip install django-redis
# In Django settings.py:
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
}
}
# Use cache:
from django.core.cache import cache
cache.set('key', 'value')
value = cache.get('key')
Requires a running Redis server (2.8+) and Django 5.2+, Python 3.10+.
Verify before relying
- Whether compression libraries (lz4, pyzstd) are automatically installed or optional dependencies.
- Performance characteristics compared to other Django cache backends in typical workloads.
- Specifics of how pluggable clients and parsers extend the default behavior.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — Django, redis, typing_extensions |
| Maintenance | actively maintained — 73 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 12,685,319/month — #1,312 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_redis-7.0.0-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
django-cache-urlConfigures Django cache backends from…
permissive · top 15,000 on PyPI
django-redis-sessionsProvides a Redis-backed session storage backend…
permissive · top 15,000 on PyPI
django-valkeyProvides a Valkey cache and session backend for…
permissive · top 15,000 on PyPI
django-cacheopsAutomatic and manual ORM query caching for…
permissive · top 5,000 on PyPI
walrusWalrus extends the redis-py client with…
unclear · top 15,000 on PyPI
cashewsAsync cache framework with decorator and direct…
permissive · top 15,000 on PyPI
BeakerBeaker provides session management and caching…
permissive · top 15,000 on PyPI
pyramid-session-redisProvides server-side session storage for…
permissive · top 15,000 on PyPI
django-constanceDjango-constance lets you store and manage…
permissive · top 5,000 on PyPI
aiocacheProvides asyncio-compatible caching with…
unclear · top 5,000 on PyPI