python - How to exclude a queryset of users from all users in django? -


i developing django rest api using drf , in 1 of views override get_queryset function:

class usersearchlistview(generics.listapiview):      ...      def get_queryset(self):         current_user_friends = friend.objects.friends(self.request.user)         all_users = user.objects.all()         # all_users queryset need remove current_user_friends queryset.         # should exclude function used? 

from all_users queryset need exclude user making request , same user's friends contained in current_user_friends queryset. how can this?

something like:

all_users = [1,2,3,4] current_user_friends = [1,2] print list(set(all_users)-set(current_user_friends)) print [user user in all_users if user not in current_user_friends] print filter(lambda user: user not in current_user_friends, all_users) 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -