django-redis is a full-featured Redis cache backend for Django, providing robust integration with Redis as Django's caching system. The current version is 6.0.0, released in June 2025, and it typically sees several updates per year, following Django's release cycle.
pip install django-redisVerified import paths — ran on the pinned version, not inferred.
To get started, configure the `CACHES` setting in your Django project's `settings.py` file to use `django_redis.cache.RedisCache` as the backend. Specify the Redis connection string in `LOCATION` and any desired `OPTIONS` like client class or serializer. Once configured, you can interact with the cache using Django's standard `django.core.cache.cache` object.
Ensure `pip install hiredis` is run, then add `"PARSER_CLASS": "redis.connection.HiredisParser"` to the `OPTIONS` dictionary in your `CACHES` configuration.
Consult the `django-redis` GitHub releases or documentation (e.g., `requires_python` field) for the supported Django versions before upgrading either library.
For improved security and interoperability, configure a different serializer, such as JSON, by setting `"SERIALIZER": "django_redis.serializers.json.JSONSerializer"` in your `CACHES OPTIONS`.
Double-check the Redis URI format in your `settings.py` (e.g., `redis://127.0.0.1:6379/1`). Ensure the Redis server is running and accessible from the Django application's host and port.
Install the package using `pip install django-redis`. If using a `requirements.txt` file, ensure `django-redis` is listed and the environment (e.g., Docker image) is rebuilt.
Verify that the Redis server is running and accessible at the specified host and port. In `settings.py`, ensure the `LOCATION` in your `CACHES` configuration is correct (e.g., `redis://127.0.0.1:6379` for local or `redis://redis:6379` if using Docker Compose service named 'redis'). Check firewall rules and Docker network configurations.
Ensure that `CACHES` is properly defined in your `settings.py` file. If running standalone scripts or in the Django shell, ensure the `DJANGO_SETTINGS_MODULE` environment variable is set or `django.setup()` is called before accessing any Django settings. Avoid importing `cache` at the top level of modules that are loaded very early in the Django startup process.
Correct the `BACKEND` setting in your `CACHES` configuration from `'django.core.cache.backends.redis.RedisCache'` to `'django_redis.cache.RedisCache'`.