Python django模板代码未加载:";TemplateSyntaxError:第19行的块标记无效:';applink';。您是否忘记注册或加载此标签?“;
我正在用Django 1.9.4和Python3.4构建一个Django应用程序。我不断得到错误:Python django模板代码未加载:";TemplateSyntaxError:第19行的块标记无效:';applink';。您是否忘记注册或加载此标签?“;,python,html,django,templates,Python,Html,Django,Templates,我正在用Django 1.9.4和Python3.4构建一个Django应用程序。我不断得到错误: Error during template rendering In template /home/enlighter/workspace/ndl-question-papers-search-hub/qp_search_project/templates/base.html, error at line 19 block tag on line 19: 'applink'. Did you f
Error during template rendering
In template /home/enlighter/workspace/ndl-question-papers-search-hub/qp_search_project/templates/base.html, error at line 19
block tag on line 19: 'applink'. Did you forget to register or load this tag?
14 <body>
15 <div class="navbar navbar-inverse navbar-fixed-top">
16 <div class="container">
17 <div class="navbar-header">
18 <a href="http://ndl.iitkgp.ac.in/" class="navbar-brand"><img src="{% static "images/ndl-logo.png" %}" height="21" /></a>
19 <a href="{% applink "/" %}" class="navbar-brand">NDL QP</a>
20 </div>
21
上面带有“{%applink”/“%}”
的html代码位于base.html中,我的search/index.html是:
{% extends "base.html" %}
{% block title %}
Search Question Papers
{% endblock %}
{% block content %}
blah blah blah
{% endblock %}
在我的应用程序的views.py
中呈现这个index.html
页面的方法是:
from django.shortcuts import render
from django.http import HttpResponse
from .forms import NameForm
applink = "/searcher"
def index(request):
context_dict = {
'applink' : applink
}
return render(request, 'searcher/index.html', context_dict)
我正在尝试从上下文中呈现“applink”,并向其追加/
?换句话说,我想呈现'/searcher/'
请帮忙
此Django项目代码位于存储库中:
要呈现上下文对象,应该使用
{{applink}
而不是{%applink%}
在模板中:
替换此项:
<a href="{% applink "/" %}" class="navbar-brand">NDL QP</a>
为此:
<a href="{{ applink }}/" class="navbar-brand">NDL QP</a>
Read要呈现上下文对象,您应该使用
{{applink}
而不是{%applink%}
在模板中:
替换此项:
<a href="{% applink "/" %}" class="navbar-brand">NDL QP</a>
为此:
<a href="{{ applink }}/" class="navbar-brand">NDL QP</a>
阅读您没有名为
applink
的templatetag您是否试图从上下文呈现applink
,并将/
附加到它?换句话说,是否要呈现“/searcher/”
?请解释您在此处尝试执行的操作。@v1k45是的,您没有名为applink
的模板标记。您是否尝试从上下文呈现applink
,并将//code>附加到它?换句话说,是否要呈现“/searcher/”
?请解释您在此处尝试执行的操作。@v1k45是的,正是这样哦!谢谢@v1k45!哦谢谢@v1k45!