0👍
✅
If I get this right you want all the User of a specific account. Given that, you should be able to do the following, or something similar.
users = User.objects.filter(userprofile__account=account)
2👍
You can avoid the additional db lookups per profile by using the select_related
.
profiles = account.select_related().profiles
will also include all user lookups within the only query.
Here is the documentation: http://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related
- [Answered ]-How to set 2 rows to become header in a dataframe with originally has a header?
- [Answered ]-Django – order queryset result by update time of instances
- [Answered ]-Custom Django Authentication
- [Answered ]-Error with docker-compose and django
- [Answered ]-Storing subprocess object in memory using global singleton instance
Source:stackexchange.com