我收到此错误,我不明白为什么。我正在填写表格,但说不是。如果需要,请询问更多代码。
class="errorlist"><li>name<ul class="errorlist"><li>This field is
required.</li></ul></li></ul>
形式:
from django import forms
class WorkFlowForm(forms.Form):
name = forms.CharField(max_length=128, help_text="Please enter the
workflow name.")
视图中:
def workflow_search_form(request):
form = WorkFlowForm(request.POST)
if request.method == 'POST':
print form
if form.is_valid():
return workflow_search(request, form.cleaned_data['name'])
else:
print(form.errors)
return render(request, 'find/list.html', {'form': form})
在html中:
<form id="WorkFlowForm" method="post" action="/find/workflow_search/">
{% csrf_token %}
{% for field in form.visible_fields %}
{{ field.errors }}
{{ field.help_text }}
{{ field }}
{% endfor %}
<input type="submit" name="name" value="Buscar workflow"/>
</form>
在网址中:
from django.conf.urls import url
from find import views
urlpatterns = [
url(r'^$', views.workflow_list, name='workflow_list'),
url(r'^workflow_list_by_category/(?P<category_slug>[\w\-]+)/$', views.workflow_list, name='workflow_list_by_category'),
url(r'^workflow_detail/(?P<id>[^/]+)/(?P<slug>[^/]+)/$', views.workflow_detail, name='workflow_detail'),
url(r'^workflow_search/$', views.workflow_search_form, name='workflow_search'),
]