python - 我不想在 html 中显示表单的标签
问题描述
我不想在 html 中显示表单的标签。我写在forms.py
class SearchForm(forms.Form):
keyword = forms.CharField(min_length=2, max_length=100)
在views.py中
def index(request):
form = SearchForm()
return render(request, 'index.html',{'form':form})
在 index.html 中
<div>
<form action="{% url 'app:search' %}" method="POST">
<table>
{{ form|as_bootstrap }}
</table>
<input type="image" src="{% static 'app/box.png' %}">
{% csrf_token %}
</form>
</div>
当我运行应用程序时,会显示表单标签的关键字。我不想展示它。我的代码有什么问题?我读了as_p
删除表单的标签,所以我重写了代码,
{{ form.as_p|as_bootstrap }}
但它仍然是一样的。我应该如何解决这个问题?
解决方案
推荐阅读
- flutter - BloC 的 TextEditingController 异常
- ios - FileHandle 在 iOS 中导致内存泄漏
- python - 给定一个相同长度的非空字符串列表,如何在不使用 zip 的情况下创建字符串中每个位置的字母列表?
- css - 在 CSS 网格线框中设置左右页脚
- oracle-apex - 没有 Oracle Apex 文本的应用程序错误自定义文本和按钮
- apache-kafka - 消费者如何在 Active 中设置 - Active Kafka 设置
- laravel - 如何在 laravel 请求中验证表单输入数组的至少一个值?
- c++ - 为什么此代码会给出错误“无法将'char *&'类型的非常量左值引用绑定到'char *'类型的右值”
- spring - 使用 POSTMAN 的跨域请求 -401
- python - 将 None 值分配给任意类的所有参数'