Skip to content

Commit

Permalink
Django 1.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Frens Jan Rumph committed Dec 16, 2014
1 parent 03c5489 commit e1d9c04
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion multidb/__init__.py
Expand Up @@ -29,7 +29,9 @@
"""
import itertools
import random
from distutils.version import LooseVersion

import django
from django.conf import settings

from .pinning import this_thread_is_pinned, db_write # noqa
Expand All @@ -45,7 +47,10 @@
slaves = itertools.cycle(dbs)
# Set the slaves as test mirrors of the master.
for db in dbs:
settings.DATABASES[db]['TEST_MIRROR'] = DEFAULT_DB_ALIAS
if LooseVersion(django.get_version()) >= LooseVersion('1.7'):
settings.DATABASES[db].get('TEST', {})['MIRROR'] = DEFAULT_DB_ALIAS
else:
settings.DATABASES[db]['TEST_MIRROR'] = DEFAULT_DB_ALIAS
else:
slaves = itertools.repeat(DEFAULT_DB_ALIAS)

Expand Down

0 comments on commit e1d9c04

Please sign in to comment.