Django Library Users
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

forms.py 604B

123456789101112131415161718192021222324
  1. from django import forms
  2. from django.contrib.auth.models import User
  3. from django.contrib.auth.forms import UserCreationForm
  4. from .models import UserProfile
  5. class UserRegistrationForm(UserCreationForm):
  6. email = forms.EmailField()
  7. class Meta:
  8. model = User
  9. fields = ['username', 'email', 'password1', 'password2']
  10. class UserProfileForm(forms.ModelForm):
  11. class Meta:
  12. model = UserProfile
  13. fields = ['timezone', 'language_code']
  14. class UserProfileFormLanguageOnly(forms.ModelForm):
  15. class Meta:
  16. model = UserProfile
  17. fields = ['language_code']