Category Navigation

2 views
Skip to first unread message

dagmar

unread,
Nov 5, 2009, 7:07:26 PM11/5/09
to Satchmo users
Hi,

I am new to both Django and Satchmo.

On my category.html template page I want to be able to show the child
categories but not the grandchildren etc. I want to do this with plain
HTML. Searching the list it would seem that using
context_processors.py is the way to do it but I don't know how to
restrict the listing to one level below the current level.

Using

{% for cats in categories %}
{{ cats }}

gives me the whole tree.


Any tips would be appreciated.


Dagmar.

Bob Waycott

unread,
Nov 6, 2009, 9:36:53 AM11/6/09
to satchm...@googlegroups.com
I don't have a category system built up currently to play with myself for this purpose, but I would suggest using the Python shell to load up a category with children and grandchildren and use the shell to play around with manipulating the resulting QuerySet to have the tree items you want. Then translate what works to your views/templates. 

dagmar

unread,
Nov 6, 2009, 10:28:23 AM11/6/09
to Satchmo users

Hi Bob,

Thanks for the reply. I am new to Django and Satchmo and I am not sure
how to test this in the shell. If I use this in my category.html
template

{% for cats in categories %}
{{ cats }}

I get

child1
grandchild1
greatgrandchild
garndchild2
child2
child3

When I am showing the page child1 I only want to provide links to
grandchild1 and grandchild2. When I am showing grandchild1 I only want
to show a link to greatgrandchild. I just do not understand how to
filter out the other levels.

As an alternative I could use

{% for cat in child_categories %}

but this is not suitable because it gives me relative links but they
are all <li> rather than nested <ul>.

Sorry for my lack of understanding.

Dagmar.
Reply all
Reply to author
Forward
0 new messages