From ec2fc0e18a490634a2da97a16ac94725c3acdc32 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 16 Sep 2021 10:29:22 +0200 Subject: Migration to Django 2.2 - fixes - rel -> remote_field - to -> model - default initialization for historical models --- ishtar_common/models.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b4d6eb0f2..6783a89b5 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -349,8 +349,13 @@ class HistoryModel(models.Model): if not models.endswith(".models"): models += ".models" models = import_module(models) - model = getattr(models, self.__class__.__name__[len("Historical") :]) - related_model = getattr(model, key).rel.model + model = getattr(models, self.__class__.__name__[len("Historical"):]) + field = getattr(model, key) + if hasattr(field, "rel"): + field = field.rel + else: + field = field.remote_field + related_model = field.model return related_model.history_decompress(self.history_m2m[key], create=create) @@ -4325,7 +4330,7 @@ class Document( def get_query_owns(cls, ishtaruser): query_own_list = [] for rel_model in cls.RELATED_MODELS: - klass = getattr(cls, rel_model).rel.related_model + klass = getattr(cls, rel_model).remote_field.related_model q_own_dct = klass._get_query_owns_dicts(ishtaruser) if q_own_dct: query_own_list.append((rel_model + "__", q_own_dct)) -- cgit v1.2.3