Django -- How to filter objects with an "author" from a set of "authors"(users)?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Drifting Through My Dreams
--
Chapters
00:00 Question
01:35 Accepted answer (Score 6)
02:03 Answer 2 (Score 5)
02:13 Answer 3 (Score 0)
02:24 Thank you
--
Full question
https://stackoverflow.com/questions/2356...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #database #django #djangomodels
#avk47
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Drifting Through My Dreams
--
Chapters
00:00 Question
01:35 Accepted answer (Score 6)
02:03 Answer 2 (Score 5)
02:13 Answer 3 (Score 0)
02:24 Thank you
--
Full question
https://stackoverflow.com/questions/2356...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #database #django #djangomodels
#avk47
ACCEPTED ANSWER
Score 6
Something like:
Post.objects.filter(author=user)
Where user is the relevant user should work, but it's hard to give a good answer with no models
EDIT
Now that I understand your question, try this:
Post.objects.filter(author__in=users)
Where users is the set of users
ANSWER 2
Score 5
Post.objects.filter(author__in=setofusers)
ANSWER 3
Score 0
Post.objects.filter(attribute__in = list_of_ids)