行上无效的块标记...:“endblock”,预期为“endwith”。您是否忘记注册或加载此标签?

问题描述 投票:0回答:1

我的 Python 项目有问题 这是位于 Django 模板中的代码

{% extends "base.html" %}
{% load django_bootstrap5 %}

{% block content %}
  <form method="post">
    {% csrf_token %}
    {% bootstrap_form form %}
    {% bootstrap_button button_type="submit" content="Отправить" %}
  </form>
  **{% with data=request.POST %}**
{% endblock %} 

当我重新加载页面时,我在屏幕截图上收到错误消息。 error screen 删除该字符串后,一切正常。 {% with data=request.POST %}

我不明白什么问题???

我试图删除该字符串,这会导致错误,这有帮助,但根据任务的条件,该字符串必须位于该代码块中

python django syntax-error
1个回答
0
投票

您需要添加

endwith
,并使用有效的语法。

试试这个:

{% extends "base.html" %}
{% load django_bootstrap5 %}

{% block content %}
  <form method="post">
    {% csrf_token %}
    {% bootstrap_form form %}
    {% bootstrap_button button_type="submit" content="Отправить" %}
  </form>
  {% with data=request.POST %}
  {% endwith %} 
{% endblock %} 
© www.soinside.com 2019 - 2024. All rights reserved.