diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index 93e7adb76e..23a61ef859 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -31,7 +31,12 @@ BACKENDS = { 'dummy': 'dummy', } -def get_cache(backend_uri): +def parse_backend_uri(backend_uri): + """ + Converts the "backend_uri" into a cache scheme ('db', 'memcached', etc), a + host and any extra params that are required for the backend. Returns a + (scheme, host, params) tuple. + """ if backend_uri.find(':') == -1: raise InvalidCacheBackendError, "Backend URI must start with scheme://" scheme, rest = backend_uri.split(':', 1) @@ -48,6 +53,10 @@ def get_cache(backend_uri): if host.endswith('/'): host = host[:-1] + return scheme, host, params + +def get_cache(backend_uri): + scheme, host, params = parse_backend_uri(backend_uri) if scheme in BACKENDS: module = __import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']) else: diff --git a/django/db/backends/creation.py b/django/db/backends/creation.py index aba41fb3f9..1bdce1ee59 100644 --- a/django/db/backends/creation.py +++ b/django/db/backends/creation.py @@ -315,7 +315,8 @@ class BaseDatabaseCreation(object): call_command('syncdb', verbosity=verbosity, interactive=False) if settings.CACHE_BACKEND.startswith('db://'): - cache_name = settings.CACHE_BACKEND[len('db://'):] + from django.core.cache import parse_backend_uri + _, cache_name, _ = parse_backend_uri(settings.CACHE_BACKEND) call_command('createcachetable', cache_name) # Get a cursor (even though we don't need one yet). This has