diff --git a/wcivf/apps/parties/importers.py b/wcivf/apps/parties/importers.py index 07e947e88..cfc57a314 100644 --- a/wcivf/apps/parties/importers.py +++ b/wcivf/apps/parties/importers.py @@ -118,7 +118,7 @@ def add_local_party(self, row, party, ballots, file_url): # only create local parties for ballots where a candidate is standing # for the parent party ballots = ballots.filter(personpost__party=party) - for post_election in ballots.distinct(): + for post_election in ballots.select_related("election").distinct(): country = self.get_country( election_type=post_election.election.election_type )