django template extends not working

后端 未结 2 1304
终归单人心
终归单人心 2021-01-04 08:00

This is my base.html

 
 
 My Site 
 

相关标签:
2条回答
  • 2021-01-04 08:37

    For more people who end up here (as myself), main thing to note is that when you use {% extends 'something.html' %}, you cannot use anything other than these template tags at the top-level.

    You can obviously have html tags inside these tags (like block tags), but don't put ANYTHING outside the template tags.

    0 讨论(0)
  • 2021-01-04 08:52

    Well everything is fine, the trouble that you are having is that you are confused, just naming a block in base does not calls it. Mark the difference between extends and include. You have counfused extends to include.

    Once in your views if you call say index.html it will be rendered properly. The effect you want can be achieved by changing the base.html in your views to index.html.

    Hope this helps. more can be read here: https://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance

    0 讨论(0)
提交回复
热议问题