Python Django编写您的第一个Django应用程序第5部分
我正在使用下面的教程网站,虽然我遵循了网站上的所有说明,但出现了这个错误 docs.djangoproject.com/en/3.0/intro/tutorial05/ (python外壳)Python Django编写您的第一个Django应用程序第5部分,python,django,django-models,django-rest-framework,Python,Django,Django Models,Django Rest Framework,我正在使用下面的教程网站,虽然我遵循了网站上的所有说明,但出现了这个错误 docs.djangoproject.com/en/3.0/intro/tutorial05/ (python外壳) index.html: <h1>{{ question.question_text }}</h1> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{%
index.html
:
<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>
{%ls if latest_question_list %}
<ul>
{% for question in latest_question_list %}
<li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>
{% endfor %}
</ul> {% else %}
<p>No polls are available.</p> {% endif %}
<h1>{{ question.question_text }}</h1>
<ul> {% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }} -- {{ achoice.votes }} vote{{ choice.votes|pluralize }}</li> {% endfor %} </ul>
<a href="{% url 'polls:detail' question.id %}">Vote again?</a>
错误消息指向模板中的错误:
TemplateSyntaxError:第1行的块标记无效:“ls”。您是否忘记注册或加载此标签?
查看您的index.html
模板,我们看到
{%ls如果是最新的问题列表%}
ls
不是有效的模板标记。删除它:
{%if最新问题列表%}
您的错误消息指向模板中的错误:
TemplateSyntaxError:第1行的块标记无效:“ls”。您是否忘记注册或加载此标签?
查看您的index.html
模板,我们看到
{%ls如果是最新的问题列表%}
ls
不是有效的模板标记。删除它:
{%if最新问题列表%}
“TemplateSyntaxError:第1行的块标记无效:“ls”-请向我们展示您的模板。对于出现的问题,非常抱歉。我在template/base.py中粘贴了这些行。这不是正确的文件。请出示您的模板。HTML文件。很抱歉给您带来不便。。。我将代码粘贴到模板directoryindex.HTML的3个HTML文件中,{%ls if..
,第1行的“TemplateSyntaxError:无效块标记:'ls'是什么?”-请给我们看一下你的模板。很抱歉给你添麻烦。我在template/base.py中粘贴了行。那不是正确的文件。请给我们看一下你的模板。HTML文件。很抱歉给你带来不便…我将代码粘贴到了模板directoryindex.HTML中的我的3个HTML文件中。{%ls if…
,那是什么
<h1>{{ question.question_text }}</h1>
<ul> {% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }} -- {{ achoice.votes }} vote{{ choice.votes|pluralize }}</li> {% endfor %} </ul>
<a href="{% url 'polls:detail' question.id %}">Vote again?</a>