Malcolm Tredinnick wrote: > On Sat, 2006-04-01 at 00:11 -0800, shredwheat wrote: >> Using a hierarchy of models like the example shown on this cookbook >> page. How do you query for the root level objects? Can it be done with >> a single query? Or do I loop over and test on the Python side? >> >> http://code.djangoproject.com/wiki/CookBookCategoryDataModel > > The root categories are the things without parents. So construct a > filter that selects all the objects with a NULL parent_id field.
In your get_list(...) or filter(...) (depending on Django version as appropriate), you have a parent_id__isnull=True as one of the arguments. (Note the double underscore before isnull and the single underscore before id.) -- --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 -~----------~----~----~----~------~----~------~--~---