[Answer]-Single Address Linked to Multiple Users Even when Using OneToOneField(User)

1👍

The issue lies at that line:

address = UserAddress.objects.get()

As you do you not specify query parameters when trying to retrieve the address, Django retrieves the only address that you have in your database (if you had more than one or no address, it would fail). So you are always editing the same object.

I guess that what you are trying to do is:

address = UserAddress.objects.get(user=user)

Which will retrieve the address for the user.
It is assuming that the user does have an address, if he does not, it will fail.

👤aumo

Leave a comment