为了简化前端form表单代码
创建一个表单类
from django import forms
class RegisterForm(forms.Form):
reg_name = forms.CharField(max_length=10, label='用户名')
reg_pwd = forms.CharField(max_length=20, label='密码', widget=forms.PasswordInput())
reg_home = forms.ChoiceField(label='籍贯', choices=((1, "北京"), (2, "上海"), (3, "广州")))
gender = forms.ChoiceField(label='性别', choices=((1, "男"), (2, "女")), widget=forms.RadioSelect())
此次框选的form即对应上图html中框选的form
(四)urls.py设置路由,而后在网页前端便可操作