mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
Added ability to specify the redis connection parameter as an URL. Fixes #26.
This commit is contained in:
parent
c2c64f7d44
commit
21344d9168
2 changed files with 8 additions and 1 deletions
|
|
@ -69,6 +69,10 @@ The is the default backend and has a couple of options:
|
|||
'db': 0,
|
||||
}
|
||||
|
||||
Alternatively you can use a URL to do the same::
|
||||
|
||||
CONSTANCE_REDIS_CONNECTION = 'redis://username:password@localhost:6379/0'
|
||||
|
||||
* ``CONSTANCE_REDIS_CONNECTION_CLASS``
|
||||
|
||||
An (optional) dotted import path to a connection to use, e.g.::
|
||||
|
|
|
|||
|
|
@ -25,7 +25,10 @@ class RedisBackend(Backend):
|
|||
except ImportError:
|
||||
raise ImproperlyConfigured(
|
||||
"The Redis backend requires redis-py to be installed.")
|
||||
self._rd = redis.Redis(**settings.REDIS_CONNECTION)
|
||||
if isinstance(settings.REDIS_CONNECTION, basestring):
|
||||
self._rd = redis.from_url(settings.REDIS_CONNECTION)
|
||||
else:
|
||||
self._rd = redis.Redis(**settings.REDIS_CONNECTION)
|
||||
|
||||
def add_prefix(self, key):
|
||||
return "%s%s" % (self._prefix, key)
|
||||
|
|
|
|||
Loading…
Reference in a new issue