On Thu, 2006-07-13 at 22:03 -0500, Chris Moffitt wrote:
> I'm using the recipe here 
> (http://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic) 
> for a category model.  It's working well for the most part. 
> 
> I am getting a little stuck trying to figure out how to turn it into a 
> vertical navigation structure.  I've looked at 
> http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal but I 
> think this is not as nice from an admin perspective so I'm not using it. 
> 
> My category structure might look like books :: non-fiction :: technical 
> :: Django for Dummies
> 
> How can I create some sort of menu structure like I've shown below?
> 
> Books
>   ->Non-fiction
>          ->History
>          ->Biographies
>           ->Technical
>   ->Fiction
> Movies
> Games
> 
> I'm a little worried that all the recursion could get painful from a 
> performance perspective & I figure this is a common enough situation 
> that maybe someone else already has something that works pretty well.

It's not too bad to do the obvious thing. I do something similar in the
sidebar of http://www.pointy-stick.com/blog/ and on
http://www.pointy-stick.com/blog/topics/ .

I'm not nearly as cool as Ian Holsman, so I don't have a version control
respository online. You can grab the source code from
http://www.pointy-stick.com/software/website-latest.tar.gz and have a
look, though. It's basically the recursion approach you are talking
about. Performance isn't too bad for "reasonable" levels of nesting.

Start at weblog/templatetags/mt_weblog.py (TagCloud.render, in
particular) and work back to the Tag model.

Once we get model-aware validators in place, I intend to switch to using
a slightly different encoding for tag sub-trees, as mentioned in the
comments in weblog/models.py, so I haven't worked too hard on making
this neat and spiffy yet as the "extract all tags" portion can be done
in a single query with a slightly different model setup.

Regards,
Malcolm



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