I'm trying to make my page in seperate parts - and one of them goes for the top menu, so far, however, I can't figure out how to include the top menu template in the rest of the pages. {% include "top_menu.html" %}
for some reason doesn't work, do I have to update my views or smthn for it to take effect?
我试图让我的页面处于单独的部分 - 其中一个用于*菜单,但到目前为止,我无法弄清楚如何将顶部菜单模板包含在其余页面中。由于某种原因{%include“top_menu.html”%}无效,我是否必须更新我的观点或smthn才能生效?
Thanks in advance!
提前致谢!
1 个解决方案
#1
7
I had same issue and have seen quite a few other similar posts. In my case the issue was caused by my outer template having {% load staticfiles %}
which was also needed by the included file.
我有同样的问题,并看过很多其他类似的帖子。在我的情况下,问题是由我的外部模板{%load staticfiles%}引起的,这也是包含文件所需要的。
The fix was to repeat {% load staticfiles %}
inside the included file. The problem was made difficult by Django not giving an error message when it failed to load the include file, so there weren't any clues.
修复是在包含的文件中重复{%load staticfiles%}。当Django无法加载包含文件时没有给出错误消息,这个问题变得很困难,因此没有任何线索。
#1
7
I had same issue and have seen quite a few other similar posts. In my case the issue was caused by my outer template having {% load staticfiles %}
which was also needed by the included file.
我有同样的问题,并看过很多其他类似的帖子。在我的情况下,问题是由我的外部模板{%load staticfiles%}引起的,这也是包含文件所需要的。
The fix was to repeat {% load staticfiles %}
inside the included file. The problem was made difficult by Django not giving an error message when it failed to load the include file, so there weren't any clues.
修复是在包含的文件中重复{%load staticfiles%}。当Django无法加载包含文件时没有给出错误消息,这个问题变得很困难,因此没有任何线索。