[Answered ]-Associating ForeignKey on auth.User model

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

👤lprsd

Leave a comment