示例:
class FM(forms.Form):
user = forms.CharField(error_messages={'required':'用户名不能为空'})
user = forms.CharField(
min_length=6,
max_length=12,
error_messages={'required':'密码不能为空', 'invalid':'密码格式错误'}
)
email = forms.EmailField(error_messages={'required':'邮箱不能为空', 'invalid':'邮箱格式错误'})
def fm(request):
if request.method == 'GET':
return render(request, 'fm.html')
elif request.method == 'POST':
网友评论