Thanks, Andy. I'll give that a try!

Corey

On Jul 18, 2006, at 9:35 PM, Andrew wrote:

>
> Here's how I did it for a similar situation I had.
>
> class MyCategory(models.Model):
>     category = models.CharField(maxlength=50)
>     parent_category = models.ForeignKey('self', blank=True,
>             null=True, related_name='sub_categories')
>
>     def all_items(self):
>         data = list(self.items.all())
>         for cat in self.sub_categories.all():
>             data.append(list(cat.all_items()))
>         return data
>
> class MyItem(models.Model):
>     name = models.CharField(maxlength=100)
>     categories = models.ManyToManyField(MyCategory,
> related_name='items')
>
> This is not the most effecient way of doing things since the list
> command forces the queryset to evaluate completely.  Perhaps we should
> consider adding a UNION function to combine QuerySets if it's not
> already in there.
>
> Andy
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to