diff --git a/src/representatives/contrib/parltrack/import_representatives.py b/src/representatives/contrib/parltrack/import_representatives.py index d0f5e70d0859376532d2c4d7cf89cbd2e156740d..e4e347b0786c2dcd2c693cc5035cda6cb3b03cfc 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