【问题标题】:Django Invalid block tag expected 'empty' or 'endfor'Django 无效的块标记应为“空”或“endfor”
【发布时间】:2014-11-19 18:14:00
【问题描述】:

我正在尝试显示诊所列表,但我不断收到以下错误:

Exception Type: TemplateSyntaxError at /clinics/
Exception Value: Invalid block tag: 'c.name', expected 'empty' or 'endfor'

这里是clinicList.html

{% for c in clinics %}
    {% c.name %}
{% endfor %}

这里是观点

def clinicList(request):
    d = getVariables(request,dictionary={'page_name':""})
    d.update({'clinics': Clinic.objects.all()})

    return render(request, 'm1/clinicList.html', d)

这里是 url.py

url(r'^clinics/$', views.clinicList, name='clinicList'),

【问题讨论】:

  • 不应该是{{ c.name }}
  • 非常感谢!不敢相信我犯了这样一个微不足道的错误。您可以将其发布为答案,我可以将其标记为已选中
  • 每个人都时不时需要这种帮助。

标签: python django


【解决方案1】:

看起来你应该有{{ c.name }}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-03
    • 2012-05-03
    • 2015-07-08
    • 2019-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-11
    相关资源
    最近更新 更多