mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
Raise an ImproperlyConfigured exception if the Redis backend is used (default) and redis-py can't be found.
This commit is contained in:
parent
82e19cec9f
commit
028dd17b93
1 changed files with 7 additions and 1 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from constance import settings, utils
|
||||
from constance.backends import Backend
|
||||
|
||||
|
|
@ -16,7 +18,11 @@ class RedisBackend(Backend):
|
|||
if connection_cls is not None:
|
||||
self._rd = utils.import_module_attr(connection_cls)()
|
||||
else:
|
||||
import redis
|
||||
try:
|
||||
import redis
|
||||
except ImportError:
|
||||
raise ImproperlyConfigured(
|
||||
"The Redis backend requires redis-py to be installed.")
|
||||
self._rd = redis.Redis(**settings.REDIS_CONNECTION)
|
||||
|
||||
def get(self, key):
|
||||
|
|
|
|||
Loading…
Reference in a new issue