cleanup: remove code for django < 1.11
@@ -59,17 +59,7 @@ def default_fallback():
MODELTRANSLATION_FALLBACK_LANGUAGES=(mt_settings.DEFAULT_LANGUAGE,))
-class dummy_context_mgr():
- def __enter__(self):
- return None
-
- def __exit__(self, _type, value, traceback):
- return False
-
-
def get_field_names(model):
- if django.VERSION < (1, 9):
- return model._meta.get_all_field_names()
names = set()
fields = model._meta.get_fields()
for field in fields:
@@ -100,9 +90,6 @@ class ModeltranslationTransactionTestBase(TransactionTestCase):
if not ModeltranslationTransactionTestBase.synced:
# In order to perform only one syncdb
ModeltranslationTransactionTestBase.synced = True
- mgr = (override_settings(**TEST_SETTINGS) if django.VERSION < (1, 8)
- else dummy_context_mgr())
- with mgr:
# 0. Render initial migration of auth
if MIGRATIONS:
call_command('makemigrations', 'auth', verbosity=2, interactive=False)
@@ -127,15 +114,9 @@ class ModeltranslationTransactionTestBase(TransactionTestCase):
sys.modules.pop('modeltranslation.tests.translation', None)
if MIGRATIONS:
sys.modules.pop('django.contrib.auth.models', None)
- tests_args = []
- if django.VERSION < (1, 11):
- tests_args = [cls.cache.all_models['tests']]
- cls.cache.get_app_config('tests').import_models(*tests_args)
+ cls.cache.get_app_config('tests').import_models()
if MIGRATIONS:
- auth_args = []
- if django.VERSION < (1, 11):
- auth_args = [cls.cache.all_models['auth']]
- cls.cache.get_app_config('auth').import_models(*auth_args)
+ cls.cache.get_app_config('auth').import_models()
# 4. Autodiscover
from modeltranslation.models import handle_translation_registrations
@@ -959,12 +940,8 @@ class ForeignKeyFieldsTest(ModeltranslationTestBase):
trans_real.activate("de")
test_inst2 = models.TestModel(title_en='title_en', title_de='title_de')
test_inst2.save()
- if django.VERSION >= (1, 9):
test_inst2.test_fks.set((fk_inst_de, fk_inst_both))
test_inst2.test_fks_en.set((fk_inst_en, fk_inst_both))
- else:
- test_inst2.test_fks = [fk_inst_de, fk_inst_both]
- test_inst2.test_fks_en = (fk_inst_en, fk_inst_both)
self.assertEqual(fk_inst_both.test.pk, test_inst2.pk)
self.assertEqual(fk_inst_both.test_id, test_inst2.pk)
self.assertEqual(fk_inst_both.test_de, test_inst2)
