I recently had to do something similar. The way I went about it (and I'm not sure this is the best way) is to select all of the categories, then iterate through them and build a tree, using each category's parent_id to figure out where in the tree it fits.
Then, once you've got a tree, you have to recurse through all of the nodes (categories). You can do this in your template, if you find a good "recurse" template tag (I saw a few on djangosnippets a while ago). Or you can do what I did, and recurse through the tree beforehand, building a flattened list of all the nodes, making sure to save what "level" each particular node is at. You can then output that in a template, using the level to set each li's class. Let me know if you need more help--I can send some code if you want, though I can't promise it's very good :-) -Jeff On Jul 12, 11:57 am, Nenillo <[EMAIL PROTECTED]> wrote: > Hi, > > I'm doing an app with a category model. That category model has an > autoreference field, to do multiple category levels. I'm using > models.ForeignKey('self', > null=True, blank=True) for that. The problem is that the select is > shown in a plain way and I wan to do something like: > > Cat1 > - Subcat1-1 > - Subcat1-2 > Cat2 > - Subcat2-1 > > Is there any easy way to do that? O are hint on how to do it? > > Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---