Django Library Users
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

forms.py 792B

1234567891011121314151617181920212223242526272829303132
  1. from django import forms
  2. from django.contrib.auth.models import User
  3. from django.contrib.auth.forms import UserCreationForm, UserChangeForm
  4. from .models import UserProfile
  5. class UserRegistrationForm(UserCreationForm):
  6. email = forms.EmailField()
  7. class Meta:
  8. model = User
  9. fields = ['username', 'email', 'first_name', 'last_name', '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']
  18. class UserActivationForm(UserChangeForm):
  19. password = None
  20. class Meta:
  21. model = User
  22. fields = ['is_active', 'is_staff']