![](/img/trans.png)
[英]django.template.exceptions.TemplateSyntaxError: Invalid block tag. Did you forget to register or load this tag?
[英]Invalid block tag. Did you forget to register or load this tag?
獲取無效的塊標記消息Invalid block tag on line 2: 'out'. Did you forget to register or load this tag?
塊標記Invalid block tag on line 2: 'out'. Did you forget to register or load this tag?
Invalid block tag on line 2: 'out'. Did you forget to register or load this tag?
但不知道為什么。 這是我的設置:
graphs.html
{% out %}
views.py
out = 'something to say'
template = loader.get_template('viz_proj/graphs.html')
context = {
'out' : out
}
return HttpResponse(template.render(context, request))
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'viz_proj'
]
項目heirarchy
viz_proj
|
viz_proj----------------------------------------templates
| |
settings.py--views.py--urls.py graphs.html
我想你想嘗試{{out}}而不是{%out%}。
解決方案是{{out}}
而不是{% out %}
。 這是因為out
是一個變量。
參考: https : //docs.djangoproject.com/en/1.11/topics/templates/#the-django-template-language
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.