diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-07-22 18:22:54 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-11-16 17:04:41 +0100 |
commit | 4b7bee9c426b99de56d496f20d0de604d62af899 (patch) | |
tree | d980ed6a27ce625281bc197b29c12f1ca04c8676 /ishtar_common | |
parent | 7738bc81b034ee6fe68d7b288e345f2bb56de740 (diff) | |
download | Ishtar-4b7bee9c426b99de56d496f20d0de604d62af899.tar.bz2 Ishtar-4b7bee9c426b99de56d496f20d0de604d62af899.zip |
Preventive file: work on inlines - 2
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/admin.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index bbd61f14b..b21503c35 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -46,6 +46,7 @@ from django.contrib.gis.geos import GEOSGeometry, MultiPolygon from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.geos.error import GEOSException from django.core.cache import cache +from django.core.exceptions import FieldError from django.core.serializers import serialize from django.core.urlresolvers import reverse from django.db.models.fields import ( @@ -575,11 +576,14 @@ class ImportActionAdmin(admin.ModelAdmin): elif isinstance(field, ForeignKey): if value: model = field.rel.to - try: - value = model.objects.get(**{slug_col: value}) - except model.DoesNotExist: - missing_parent.append(row.pop(k)) - continue + for slug_col2 in self.import_keys: + try: + value = model.objects.get(**{slug_col2: value}) + except FieldError: + continue + except model.DoesNotExist: + missing_parent.append(row.pop(k)) + break else: value = None row[k] = value |