diff --git a/polling_stations/apps/data_importers/management/commands/import_eoni.py b/polling_stations/apps/data_importers/management/commands/import_eoni.py index fb2573b21..0d77c7829 100644 --- a/polling_stations/apps/data_importers/management/commands/import_eoni.py +++ b/polling_stations/apps/data_importers/management/commands/import_eoni.py @@ -285,8 +285,9 @@ def assign_or_remove_left_over_addresses(self): ) if len(others_in_postcode) == 1: other_address = others_in_postcode[0] - other_uprn = other_address.uprntocouncil - other_uprn.refresh_from_db(using=DB_NAME) + other_uprn = UprnToCouncil.objects.using(DB_NAME).get( + uprn=other_address.uprn + ) self.stdout.write( f"Updating UprnToCouncil record for {address.uprn} with gss {other_uprn.lad}" )