标签:ESS nbsp blank nova label 加密 csrf 默认值 rms
参考
views
from django import forms class RegForm(forms.Form): name = forms.CharField( label=‘用户名‘, min_length=8, #最小长度 initial=‘张三‘, #默认值 error_messages={ #自定义默认提示 ‘required‘: ‘不能为空‘, ‘min_length‘: ‘长度最少为8位‘ } ) pwd = forms.CharField( label=‘密码‘, min_length=6, max_length=18, #最大长度 widget=forms.PasswordInput, #改为加密类型 ) re_pwd = forms.CharField( label=‘确认密码‘, widget=forms.PasswordInput, ) gender = forms.ChoiceField(label=‘性别 ‘,choices=((‘1‘, ‘男‘), (‘2‘, ‘女‘)),widget=forms.RadioSelect) re_gender = forms.ChoiceField(widget=forms.CheckboxInput)
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form action="" method="post" novalidate> {% csrf_token %} {# {{ form_obj.as_p }}#} <p> {{ form_obj.name.label }} {{ form_obj.name }} {{ form_obj.name.errors.0 }} </p> <p> {{ form_obj.pwd.label }} {{ form_obj.pwd }} {{ form_obj.pwd.errors.0 }} </p> <p> {{ form_obj.re_pwd.label }} {{ form_obj.re_pwd }} {{ form_obj.re_pwd.errors.0 }} </p> <p> {{ form_obj.gender.label}} {{ form_obj.gender }} {{ form_obj.gender.errors.0 }} </p> <p> {{ form_obj.re_gender.label}} {{ form_obj.re_gender }} {{ form_obj.re_gender.errors.0 }} </p> <button>注册</button> </form> </body> </html>
标签:ESS nbsp blank nova label 加密 csrf 默认值 rms
原文地址:https://www.cnblogs.com/wanglan/p/10387784.html