zoukankan      html  css  js  c++  java
  • django项目一:基于django2.2可重用登录与注册模块-注册页面

    前言

    前面我们已经完成了项目大部分内容,现在还剩下重要的注册功能没有实现。

    一、创建forms

    显而易见,我们的注册页面也需要一个form表单。同样地,在/login/forms.py中添加一个新的表单类:

    class RegisterForm(forms.Form):
        gender = (
            ("female",""),
            ("male",""),
        )
        username = forms.CharField(label="用户名", max_length=128, widget=forms.TextInput(attrs={'class': 'form-control','placeholder': "Password",}))
        password1 = forms.CharField(label="密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': "Password",}))
        password2 = forms.CharField(label="再次输入密码", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control', 'placeholder': "Password",}))
        e_mail = forms.EmailField(label="邮箱",max_length='256',widget=forms.EmailInput(attrs={'class':'form-control','placeholder':"Email"}))
        sex = forms.ChoiceField(label='性别',choices=gender)
        captcha = CaptchaField(label='验证码')

    说明:

    • gender字典和User模型中的一样,其实可以拉出来作为常量共用,为了直观,特意重写一遍;
    • password1和password2,用于输入两遍密码,并进行比较,防止误输密码;
    • email是一个邮箱输入框;
    • sex是一个select下拉框;
    • 没有添加更多的input属性

    二、完善register.html

    同样地,类似login.html文件,我们手工在register.html中编写forms相关条目:







  • 相关阅读:
    flutter 屏幕宽高 状态栏高度
    flutter 图片圆角
    flutter ListView嵌套高度问题
    Dubbo原码解析(version:2.5.3)
    ms
    InnoDB锁问题 & DB事务隔离级别
    Spring父容器与子容器
    Spring bean 的加载过程和生命周期
    logback
    Disconf (version : 2.6.21)
  • 原文地址:https://www.cnblogs.com/liushui0306/p/13058922.html
Copyright © 2011-2022 走看看