Django Console中输入命令 使用form表单
1.在views.py文件中加入下面文件:

class BookForm(forms.Form):
    title = forms.CharField(max_length=32)
    price = forms.IntegerField()
    email = forms.EmailField()

2.1 示例1

>>> from book.views import BookForm
>>> fm = BookForm({'title':'apollo', 'price':29, 'email':'12306@qq.com'})
>>> fm.is_valid()
True
>>> fm.errors
{}
>>> fm.cleaned_data
Out[17]: {'title': 'apollo', 'price': 29, 'email': '12306@qq.com'}

2.1 示例2

>>> from book.views import BookForm
>>> fm = BookForm({'title':'apollo', 'price':29, 'email':'12306'})
>>> fm.is_valid()
False
>>> fm.errors
{'email': ['输入一个有效的 Email 地址。']}