python - 无法解析剩余部分:来自“forloop .counter”的“.counter”
问题描述
< h1 > {{ question.question_text }} </ h1 >
{% if error_message %} < p >< strong > {{ error_message }} </ strong ></ p > {% endif %}
<form action = " {% url 'polls:vote' question.id %} " method = "post" >
{% csrf_token %}
{% for choice in question.choice_set.all %}
<% input type = "radio" name = "choice" id = "choice {{ forloop .counter }} " value = " {{ choice.id }} "% >
< label for = "choice {{ forloop .counter }} " > {{ choice.choice_text }} </ label >< br >
{% endfor %}
< input type = "submit" value = "Vote" >
</form >
运行命令时出现此错误:python manage.pyrunserver
django.template.exceptions.TemplateSyntaxError:无法解析剩余部分:来自“forloop .counter”的“.counter”
我该如何解决这个错误?
解决方案
推荐阅读
- python - 单词应该一个接一个地打印,但打印在一行中
- c# - Entity Framework Core 3.0 上的 HasDefaultValue() 扩展方法在哪里
- python - 如何让 SymPy 收集偏导数?
- json - 如何获取数组 json 而不是对象 json
- java - 遍历 JSON 并将列表数组添加到对象/数组中
- python - 匀称地安装python时出现Alpine错误
- spotfire - 在 Spotfire 中通过多列链接两个数据表
- stream - 流式处理 SIMD 扩展 (SSE) 中的流式处理代表什么?
- c# - 如何为具有多个参数的函数创建线程
- javascript - 将图像预加载到预缓存