To use fakeredis with the standard Django cache backend, provide FakeConnection in the OPTIONS of your CACHES setting.
If using the django-redis library, you must pass the connection class via CONNECTION_POOL_KWARGS.
# Standard Django RedisCache
from fakeredis import FakeConnection
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.redis.RedisCache",
"LOCATION": "...",
"OPTIONS": {"connection_class": FakeConnection},
}
}
# Using django-redis library
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "...",
"OPTIONS": {
"CONNECTION_POOL_KWARGS": {"connection_class": FakeConnection},
},
}
}