获取无效的块标记消息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
答案 0 :(得分:19)
我想你想尝试{{out}}而不是{%out%}。
答案 1 :(得分:2)
解决方案是{{out}}
而不是{% out %}
。这是因为out
是一个变量。
参考:https://docs.djangoproject.com/en/1.11/topics/templates/#the-django-template-language