Install
pip install django-redis
Configuration
Add CACHES
in settings.py
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
Configure session backend
If want to use session backend with django-redis
, add SESSION_ENGINE
and SESSION_CACHE_ALIAS
to settings.py
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
SESSION_CACHE_ALIAS = "default"
For more information, check django-redis documentatino
'backend > django' 카테고리의 다른 글
Django: overriding 403 page (0) | 2018.04.26 |
---|---|
Using Environment variable in uswgi.ini (0) | 2018.04.22 |
Django: get all logged-in users by using session (0) | 2018.04.15 |
Django: django channels basic usage (0) | 2018.04.06 |
Django: template tag 'now' (0) | 2018.04.05 |