I am new to django. I cannot display a template using a two or multi-level dictionary. Below are my view and template code.
code from view.py
myList = { 'ParentABC': { 'ABC' : '#' } } return render_to_response('index.html', myList)
I tried with two different templates, but no luck: Template1 -
<ul class="collapsible collapsible-accordion"> {% for eachCategory in myList %} <li class="bold"><a class="collapsible-header waves-effect waves-teal">{{ eachCategory }}</a> <div class="collapsible-body" style=""> <ul> {% for subCat in myList.eachCategory %} <li><a href="#">{{ subCat }}</a></li> {% endfor %} </ul> </div> </li> {% endfor %} </ul>
pattern 2-
<ul class="collapsible collapsible-accordion"> {% for category,value in myList.items %} <li class="bold"><a class="collapsible-header waves-effect waves-teal">{{ category }}</a> <div class="collapsible-body" style=""> <ul> {% for subcategory,value1 in value.items %} <li><a href="#">{{ subcategory }}</a></li> {% endfor %} </ul> </div> </li> {% endfor %} </ul>
after rendering, I always get below html:
<ul class="collapsible collapsible-accordion"> </ul>
Please help me for the same.
source share