Django ORM QuerySet intersection by a field
- by Sri Raghavan
These are the (pseudo) models I've got.
Blog:
name
etc...
Article:
name
blog
creator
etc
User (as per django.contrib.auth)
So my problem is this: I've got two users. I want to get all of the articles that the two users published on the same blog (no matter which blog). I can't simply filter the Article model by both users, because that would yield the set of Articles created by both users. Obviously not what I want. but can I filter somehow to get all of the articles where a field of the object matches between the two querysets?