1👍
✅
related_name defines the name of reverse relation, so in your case, there is no model with relation contact_owner_set
.
For example, if you want to access client contacts, you should use the client.contact_client
attribute; if you want to get the contact’s actions, you have to use the contact.action_contact
attribute.
But there is no relation contact_owner_set
in particular here:
self.fields['contact_owner'].queryset = self.instance.client_owner.contact_owner_set.order_by('name')
self.instance.client_owner
is Client
instance and Client
instance has no attribute contact_owner_set
.
And you definitely have to rename your related_name
by using plural for more code readability.
Source:stackexchange.com