From 1ab34e1c692400ef5e7b51b72a0a1d637d6d5f33 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 22 Jul 2021 18:22:54 +0200 Subject: Preventive file: work on inlines - 2 --- ishtar_common/admin.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'ishtar_common/admin.py') diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index 99c3b2deb..00e1b8b74 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 ( @@ -582,11 +583,14 @@ class ImportActionAdmin(admin.ModelAdmin): value = ContentType.objects.get(app_label=value[0], model=value[1]) else: - 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 -- cgit v1.2.3