forms.py 445 B

1234567891011121314151617181920
  1. # 引入表单类
  2. from django import forms
  3. # 引入 User 模型
  4. from django.contrib.auth.models import User
  5. # 登录表单,继承了 forms.Form 类
  6. class UserLoginForm(forms.Form):
  7. username = forms.CharField()
  8. password = forms.CharField()
  9. # 注册用户表单
  10. class UserRegisterForm(forms.ModelForm):
  11. # 复写 User 的密码
  12. password = forms.CharField()
  13. class Meta:
  14. model = User
  15. fields = ('username',)