Commit 2babadeb authored by Okhin's avatar Okhin

Catching the correct exceptions

parent e3889c4f
Pipeline #1089 passed with stage
in 9 minutes and 3 seconds
...@@ -11,6 +11,7 @@ from django.apps import apps ...@@ -11,6 +11,7 @@ from django.apps import apps
from django.db import transaction from django.db import transaction
from django.utils import timezone from django.utils import timezone
from django.utils.text import slugify from django.utils.text import slugify
from django.core.exceptions import MultipleObjectsReturned
from representatives.models import (Address, Constituency, Country, Email, from representatives.models import (Address, Constituency, Country, Email,
Group, Mandate, Phone, Representative, Group, Mandate, Phone, Representative,
...@@ -301,7 +302,7 @@ class ParltrackImporter(GenericImporter): ...@@ -301,7 +302,7 @@ class ParltrackImporter(GenericImporter):
except Constituency.DoesNotExist: except Constituency.DoesNotExist:
constituency = Constituency(name=local_party) constituency = Constituency(name=local_party)
save_constituency = True save_constituency = True
except Constituency.MultipleObjectsReturned: except MultipleObjectsReturned:
# There is more than one constituency with that name. # There is more than one constituency with that name.
# We must filter them by country. # We must filter them by country.
constituency = Constituency.objects.get(name=local_party, constituency = Constituency.objects.get(name=local_party,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment