私はDjango 1.9.4とPython3.4でDjangoアプリケーションを構築しています。これは私のプロジェクトのディレクトリ構造であるdjangoテンプレートコードがロードされていません: "TemplateSyntaxError:19行目の無効なブロックタグ:applink '。このタグの登録または読み込みを忘れましたか?
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
:私はエラーを得続ける
manage.py
qp_search_project
searcher
|--admin.py
|--apps.py
|--forms.py
|--static
|--css
|--models.py, etc.
templates
|--base.html
|--searcher
|--index.html
"{% applink "/" %}"
と上記のhtmlコードはbase.htmlであり、私の探索は、/ 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プロジェクトのコードリポジトリである: https://github.com/enlighter/ndl-question-papers-search-hub/tree/master/qp_search_project
あなたは 'applink'あなたが文脈から' applink'をレンダリングし、それに '/'を追加しようとしている?という名前templatetagを持っていけませんか言い換えれば、 ''/searcher/''をレンダリングしますか? – v1k45
ここで何をしようとしているか説明してください。 –
@ v1k45はいまさにその通り –