Django-forms efficacy assembly

导入:from django import forms

Create a class

class UserForm(forms.Form):
name=forms.CharField(min_length=4)
email = forms.EmailField()

In view function instantiated

form = UserForm("name"="xhl","email":"111")

Verification method

form.is_valid () # field check whether the information submitted, returns a Boolean value
1. If form.is_valid () is True form.cleaned_data return value is a dictionary, all field-tested successful, and field values,
2. if form.is_valid () returns False form.errors a dictionary for all the field validation fails, and field values, form.cleaned_data return value is the dictionary, all of the field efficacy successful, and field values,

Guess you like

Origin www.cnblogs.com/tianhen/p/11261654.html