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
Post a Comment