diff --git a/README.rst b/README.rst index 433d888..edb4aa3 100644 --- a/README.rst +++ b/README.rst @@ -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.:: diff --git a/constance/backends/redisd.py b/constance/backends/redisd.py index e512f0b..b023e38 100644 --- a/constance/backends/redisd.py +++ b/constance/backends/redisd.py @@ -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)