From 6b80f7b90c714c335533fa55ba5bf859de717e38 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 27 Oct 2017 09:50:31 +0200 Subject: Command import_geofla_csv: manage town request with year --- ishtar_common/management/commands/import_geofla_csv.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ishtar_common/management') diff --git a/ishtar_common/management/commands/import_geofla_csv.py b/ishtar_common/management/commands/import_geofla_csv.py index 80e10bc81..28c2dabf5 100644 --- a/ishtar_common/management/commands/import_geofla_csv.py +++ b/ishtar_common/management/commands/import_geofla_csv.py @@ -51,7 +51,10 @@ class Command(BaseCommand): q = Town.objects.filter(numero_insee=num_insee) changed, created = False, False if q.count(): - town = q.all()[0] + if q.filter(year=default_year).count(): + town = q.filter(year=default_year).all()[0] + else: + town = q.order_by('-year').all()[0] else: changed = True created = True -- cgit v1.2.3