Skip to content

Commit

Permalink
Get object from same database we wrote it to.
Browse files Browse the repository at this point in the history
This is just being really explicit about using the same db to get the
related UprnToCouncil object, that we've written to. We seem to be
hitting race conditions, and getting 'RelatedObjectDoesNotExist' errors.
This should fix that.
  • Loading branch information
GeoWill committed Nov 28, 2024
1 parent bf3868d commit c25086f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down

0 comments on commit c25086f

Please sign in to comment.