Russell Cloran wrote: > Hi, > > On Tue, 2006-04-11 at 21:20 -0400, Max Battcher wrote: >> if sometag.article_set.count() == 0: >> pass # your code here > > This will test if one tag has an empty article_set. AFAICT, the question > is on how to find all tags which have an empty article_set. Yes, you > could do it this way, but it means querying the DB again for every tag.
Oh, right. You could do: tags = [tag for tag in Tag.objects.all() if tag.article_set.count() == 0] n queries for n tags, but it is "pretty" Python. Doing db-cleanup shouldn't happen all that often, so you probably don't need the best performance, and I'd just stick with the list comprehension. Too bad there isn't some cool easy Python way to make a list comprehension/generators like that as Lazy as the Descriptors... Byte-code parsing, anyone? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442447 -- --Max Battcher-- http://www.worldmaker.net/ "I'm gonna win, trust in me / I have come to save this world / and in the end I'll get the grrrl!" --Machinae Supremacy, Hero (Promo Track) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---