Django query to filter out current user from a list of users -


i have query returns list of users. contains current logged in user , make same query without returning user. in models book has foreignkey library called library , library has m2m users called subscribers. it's not important simple query users should work example well.

users = book.library.subscribers.all() 

request.user ends in users , don't want that. know take out of list after making query know if there directly way exclude request.user query.

you can do

book.library.subscribers.exclude(user=request.user)  

assuming, user attribute stores users


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -