[Answered ]-User and UserProfile objects in Django

1👍

I believe that this is the way to select the UserProfile objects which are friends with a given user:

UserProfile.objects.filter(friends__user = 234)

And here are the User objects for the same set of users:

User.objects.filter(userprofile__friends__user = 234)

1👍

There isn’t just one relationship so there is more then just the two sides you are considering. A user has a relationship with a profile object (FK) and another with numerous user objects (M2M).

Leave a comment