crispy表单不起作用,我没有任何错误,但表单仍然正常。我想在这方面得到帮助。我不明白我从来没有遇到过这个问题谢谢
我在已安装的应用程序中有'crispy_forms'
,并且安装正确
我尝试了很多东西,但没有得到任何结果
newhome.html
{% load crispy_forms_tags %}
{% load static %}
{% block content %}
<link rel="stylesheet" type="text/css" href="{% static 'pools/newmain.css' %}">
<!-- Load an icon library to show a hamburger menu (bars) on small screens -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="topnav" id="myTopnav">
<a href="#home" class="active">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</div>
<div class="content-section">
<form method="POST" action="">
{% csrf_token %}
{{ form|crispy }}
<button class="btn btn-outline-info" type="submit">Send</button>
</form>
</div>
{% endblock %}
newmain.css
body {
background-color: coral;
}
/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}
/* Add an active class to highlight the current page */
.topnav a.active {
background-color: #4CAF50;
color: white;
}
/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}
views.py
def newhome(request):
form = NewTask
if request.method == "POST":
form = NewTask(request.POST)
if form.is_valid():
form.save()
task = form.cleaned_data["title"]
print(task)
else:
form = NewTask()
return render(request, "pools/newhome.html", {"form": form})
return render(request, "pools/newhome.html", {"form": form})
1.在doc中,它说:
你把所有的html文件代码都粘贴在这里了吗?我没有看到cryspy表单文档提到的任何CSS框架,例如
bootstrap4
注意,您需要将以下内容添加到
html
有关cdn2,请参见引导程序网站
别忘了删除浏览历史记录强>
您可能已将“crispy_表单”放入已安装的_应用程序中,但您是否在settings.py中指定了模板包?e、 g.
CRISPY_TEMPLATE_PACK = 'uni_form'
相关问题 更多 >
编程相关推荐