Re: Querying Exact Foreign Key Sets

2010-09-15 Thread Jason
Wow - that's *exactly* the way I ended up doing it! It took me a full working day to figure it out though. I'll post up a snippet when I'm at work tomorrow. Basically the same thing except filtering with pk and not name- I looped through the exact matches and then excluded the rest. On Sep 15,

Re: Querying Exact Foreign Key Sets

2010-09-15 Thread Alec Shaner
Try this: I'm assuming you define Article.category as a ManyToMany field? I also assumed for the example that Category has a name field. # Build a queryset of all categories not in desired set, e.g., 'Exact1' and 'Exact2' bad_categories = Category.objects.exclude(category_name__in=['Exact1', 'Exa

Querying Exact Foreign Key Sets

2010-09-14 Thread Jason
Say for example you have two models: Article Category Articles can have multiple categories. How would you go about finding the Articles that contain only a certain set of Categories? The 'in' operator doesn't do me any good. Excludes look like they are needed... I'm in a situation where qui