isn't it possible to define this in the query? to return only non empty categories? or return categories where it has more than 1 member?
On Mon, Jul 16, 2012 at 2:38 PM, Sithembewena Lloyd Dube <[email protected]>wrote: > Hi everyone, > > I have a queryset of categories and would like to exclude categories with > no items associated. I am cycling through the queryset as follows, without > the desired result: > > for cat in categories: > if cat.item_set.count() == 0: > categories.exclude(pk=cat.pk) > > How can I remove those categories (please note, I do not intend to delete > them)? > > Thanks. > -- > Regards, > Sithembewena Lloyd Dube > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

