diff --git a/django_nuts/loaders/__init__.py b/django_nuts/loaders/__init__.py index cce895a..87a8dbf 100644 --- a/django_nuts/loaders/__init__.py +++ b/django_nuts/loaders/__init__.py @@ -88,8 +88,8 @@ def load_lau(*country_codes): country_codes = (key for key in data.keys() if len(key) == 2) for country_code in country_codes: sheet = data[country_code] - nuts = {n.code: n for n in NUTS.objects.filter(code__startswith=country_code).iterator()} - laus = {l.code: l for l in LAU.objects.filter(code__startswith=country_code).iterator()} + nuts = {n_nuts.code: n_nuts for n_nuts in NUTS.objects.filter(code__startswith=country_code).iterator()} + laus = {l_lau.code: l_lau for l_lau in LAU.objects.filter(code__startswith=country_code).iterator()} created, updated = 0, 0 for row in sheet[1:]: # handle exceptions in data diff --git a/django_nuts/loaders/cz_nuts4_lau.py b/django_nuts/loaders/cz_nuts4_lau.py index da77509..1772d02 100644 --- a/django_nuts/loaders/cz_nuts4_lau.py +++ b/django_nuts/loaders/cz_nuts4_lau.py @@ -18,8 +18,8 @@ def load_cz_nuts4_lau(): # take last sheet sheet = data[list(data.keys())[-1]] - nuts = {n.code: n for n in NUTS.objects.filter(code__startswith='CZ').iterator()} - laus = {l.code: l for l in LAU.objects.filter(code__startswith='CZ').iterator()} + nuts = {n_nuts.code: n_nuts for n_nuts in NUTS.objects.filter(code__startswith='CZ').iterator()} + laus = {l_lau.code: l_lau for l_lau in LAU.objects.filter(code__startswith='CZ').iterator()} nuts_created, nuts_updated, lau_created, lau_updated = 0, 0, 0, 0 for row in sheet[2:]: lau_code, lau_name = row[0:2]