I have a model House, House has a many to many with User (called owners), and I’m looking to get all the houses a user owns (specifically the logged in user), the following:
House.objects.filter(owners__contains=request.user)
Yields an invalid lookup error, I’m assuming this is because it’s meant to do a LIKE. Though I’m unsure how else I would retrieve this data. Any ideas?
Thanks!
The correct code: