Django ORM QuerySet intersection by a field

Posted by Sri Raghavan on Stack Overflow See other posts from Stack Overflow or by Sri Raghavan
Published on 2011-01-03T11:24:12Z Indexed on 2011/01/03 11:53 UTC
Read the original article Hit count: 387

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about sql

Related posts about django