From 94bf3c4f83cfe61ee503f2012f83c898cc0480e4 Mon Sep 17 00:00:00 2001 From: Okhin Date: Wed, 31 May 2017 17:43:13 +0200 Subject: [PATCH] Let's add a filter for Multiple Constituency because nationalist have alack of imagination. --- .../contrib/parltrack/import_representatives.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/representatives/contrib/parltrack/import_representatives.py b/src/representatives/contrib/parltrack/import_representatives.py index d0f5e70..e4e347b 100644 --- a/src/representatives/contrib/parltrack/import_representatives.py +++ b/src/representatives/contrib/parltrack/import_representatives.py @@ -301,6 +301,11 @@ class ParltrackImporter(GenericImporter): except Constituency.DoesNotExist: constituency = Constituency(name=local_party) save_constituency = True + except Constituency.MultipleObjectsReturned: + # There is more than one constituency with that name. + # We must filter them by country. + constituency = Constituency.objects.get(name=local_party, + country_id=country_id) if constituency.country_id != country_id: constituency.country_id = country_id -- GitLab