1👍
✅
Your starting point is a TeamMember
, a teammember
has reverse relation to Owner
which you need to use in order to filter on Owner.report
and Owner.primary_owner
bit.
e.g.
owners = TeamMember.objects.filter(
owner__report_id=id, #its also possible to use: owner__report__id
owner__primary_owner=1 #I have no idea why you use contains on an IntegerField?
).distinct()[:1]
0👍
This should work:
primary_owner = TeamMember.objects.filter(owner__report__id=id,
owner__primary_owner=1).first()
The model name Owner
is a bit missleading, what about ReportOwnership
(or suggest any other!). Also, primary_owner should be a BooleanField
- Invitation not accepted user are also registered
- How to Install Django with command sudo
- GenericForeignKeys in Intermediate Models
- Django imageField url on html
- Is there an easy way to update a **kwarg while querying? django
Source:stackexchange.com