diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-09-16 10:29:22 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:20:58 +0100 |
commit | ec2fc0e18a490634a2da97a16ac94725c3acdc32 (patch) | |
tree | b20ee23a82f76fc63ee99417007d57f310d34ceb /ishtar_common/models_imports.py | |
parent | f2f735ed86dd12c37ded45eb0b191b02582c3d08 (diff) | |
download | Ishtar-ec2fc0e18a490634a2da97a16ac94725c3acdc32.tar.bz2 Ishtar-ec2fc0e18a490634a2da97a16ac94725c3acdc32.zip |
Migration to Django 2.2 - fixes
- rel -> remote_field
- to -> model
- default initialization for historical models
Diffstat (limited to 'ishtar_common/models_imports.py')
-rw-r--r-- | ishtar_common/models_imports.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ishtar_common/models_imports.py b/ishtar_common/models_imports.py index 54409e2c9..e530b54e3 100644 --- a/ishtar_common/models_imports.py +++ b/ishtar_common/models_imports.py @@ -339,8 +339,8 @@ def get_associated_model(parent_model, keys): ).format(item, OBJECT_CLS.__name__) ) field = fields[item] - if hasattr(field, "rel") and hasattr(field.rel, "to"): - model = field.rel.to + if hasattr(field, "remote_field") and hasattr(field.remote_field, "model"): + model = field.remote_field.model if type(field) == ModelBase: model = field else: @@ -455,9 +455,10 @@ class ImporterDefaultValues(models.Model): if target not in fields: return field = fields[target] - if not hasattr(field, "rel") or not hasattr(field.rel, "to"): + if not hasattr(field, "remote_field") or not hasattr( + field.remote_field, "model"): return self.value - model = field.rel.to + model = field.remote_field.model # if value is an id try: return model.objects.get(pk=int(self.value)) |