On 6/14/07, Young Gyu Park <[EMAIL PROTECTED]> wrote: > This is only valid when the category have one depth. > > But what about two or three depth?
Look at it carefully; it works with *any* depth of categories. To confirm, run this simplified example which uses plain Python objects instead of models: class Category(object): def __init__(self, title, parent=None): self.title = title self.parent = parent def __str__(self): if self.parent: return "%s -> %s" % (self.parent, self.title) else: return self.title A = Category(title='A') B = Category(title='B', parent=A) C = Category(title='C', parent=B) D = Category(title='D', parent=C) E = Category(title='E', parent=D) print A print B print C print D print E You'll get this output: A A -> B A -> B -> C A -> B -> C -> D A -> B -> C -> D -> E Look carefully at that __str__ method to see why this works. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---