Re: DB queries with filter and exclude

2007-08-07 Thread Nis Jørgensen
[EMAIL PROTECTED] skrev: > Wow, thanks for the reply. I can't get this to work though--I get an > "iteration over non-sequence". Can you take a look? > author.book_set is a Manager. You need author.book_set.all() (or author.book_set.all in a template) to get a QuerySet which you can iterate

Re: DB queries with filter and exclude

2007-08-06 Thread [EMAIL PROTECTED]
Wow, thanks for the reply. I can't get this to work though--I get an "iteration over non-sequence". Can you take a look? model... class Author(models.Model): first_name = models.CharField(maxlength=30) last_name = models.CharField(maxlength=40) def __str__(self):

Re: DB queries with filter and exclude

2007-08-06 Thread [EMAIL PROTECTED]
Given your view code above, what would the template code look like to return something like this: object | tags ---+-- obj1 | food, meat obj2 | food, meat obj3 | food obj4 | food, cake obj5 | food, cake obj6 | food, vegetable obj7 | garden, vegetable On Aug 6,

Re: DB queries with filter and exclude

2007-08-06 Thread Tim Chase
> Now I want to get all objects, which have set tag "food" *and* *have > not* set tag "cake". > > This get all objects with tag="food" set (obj1..obj5): > >Obj.objects.filter(tags__in=[Tags.objects.filter(name='food')]) > > This get all objects, which haven't set tag "cake" (obj1..obj3,

DB queries with filter and exclude

2007-08-06 Thread Michal
Hello, I have defined two models, one reffered from another with ManyToManyField. This referrer is used to categorising objects with 0, 1 or more tags. Now I want to get all objects, which have set tag "food" *and* *have not* set tag "cake". Example: object | tags ---+-- obj1