From 09ffa1c48942e5b831d8bc8ef0af13de93e8cabd Mon Sep 17 00:00:00 2001 From: Shun Liang Date: Sat, 10 Mar 2018 13:36:23 +0000 Subject: [PATCH] Import whole module to avoid cyclic import --- parler/models.py | 4 ++-- parler/utils/fields.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/parler/models.py b/parler/models.py index 194a68ba..57df3376 100644 --- a/parler/models.py +++ b/parler/models.py @@ -78,7 +78,7 @@ class Meta: is_missing, ) from parler.fields import TranslatedField, LanguageCodeDescriptor, TranslatedFieldDescriptor -from parler.managers import TranslatableManager +from parler import managers from parler.utils import compat from parler.utils.i18n import (normalize_language_code, get_language, get_language_settings, get_language_title, get_null_language_error) @@ -896,7 +896,7 @@ class Meta: abstract = True # change the default manager to the translation manager - objects = TranslatableManager() + objects = managers.TranslatableManager() class TranslatedFieldsModelBase(ModelBase): diff --git a/parler/utils/fields.py b/parler/utils/fields.py index 8256b849..93c3910f 100644 --- a/parler/utils/fields.py +++ b/parler/utils/fields.py @@ -1,5 +1,7 @@ from django.db.models.constants import LOOKUP_SEP from django.db import models +from parler import models as parler_models + import django.db.models.fields @@ -20,9 +22,8 @@ def get_model_from_relation(field): def get_extra_related_translation_paths(model, path): # type: (models.Model, str) -> List[str] """ - Returns paths with active and default transalation models for all Translatable models in path + Returns paths with active and default translation models for all Translatable models in path """ - from parler.models import TranslatableModel pieces = path.split(LOOKUP_SEP) parent = model current_path = '' @@ -31,7 +32,7 @@ def get_extra_related_translation_paths(model, path): field = parent._meta.get_field(piece) parent = get_model_from_relation(field) current_path += LOOKUP_SEP + piece if current_path else piece - if issubclass(parent, TranslatableModel): + if issubclass(parent, parler_models.TranslatableModel): for extension in parent._parler_meta: extra_paths.append(current_path + LOOKUP_SEP + extension.rel_name_active) extra_paths.append(current_path + LOOKUP_SEP + extension.rel_name_default)