Sorry for the badly formatted html code. My question on Stackoverflow here: 
https://stackoverflow.com/questions/64359521/djang-multiple-levels-of-template-extension-while-keeping-the-elements-of-the-up

Thanks,

On Wednesday, October 14, 2020 at 1:03:43 PM UTC-6 tristant wrote:

>
> <body> <div id="header"> ... </div> <div id="content"> {% block content 
> %} {% endblock %} </div> </body> 
>
> category.html :
> {% extends "base.html" %} {% block content %} <div class="category_row"> <
> div id="menu_category_display"> {% for category in menu_categories %} {% 
> with category_button="menu_"|add:category.name|lower %} <button class="button 
> category_buttons {{category_button}}" onclick=
> "showItem('{{category_button}}','category_buttons')"> {{category}} </
> button> {% endwith %} {% endfor %} </div> </div> <div class="item_row"> 
> {% block level_2_content %} {% endblock %} </div> </div> {% endblock %} 
>
> and item.htlm
> {% extends "category/category.html" %} {% block level_2_content %} <div 
> id="test_div"> {% for item in menu_items %} <p>{{item.name}}</p> {% 
> endfor %} </div> {% endblock %} 
>
> When item.html is rendered, all the elements that were rendered by 
> category.html are gone. Only the elements of the base.html are retained. 
>
> In the code above, the entire category_row div does not appear in 
> item.html. How do I retain them?
>
> How do I retain all elements in all parent templates instead of just 
> base.html? A general method to do this for more than 3 levels of 
> extension like in my case?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8a63dea0-5d37-4cd7-bc7d-c035410c89b8n%40googlegroups.com.

Reply via email to