admin user forms handle passwords correctly

This commit is contained in:
Sam
2021-03-25 10:16:08 +00:00
parent a13d6d1f36
commit 86aaa0ef2e
2 changed files with 36 additions and 1 deletions

27
core/forms.py Normal file
View File

@@ -0,0 +1,27 @@
from django import forms
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
from django.forms import ModelForm
from django.contrib.auth import get_user_model
User = get_user_model()
class CustomUserCreationForm(UserCreationForm):
class Meta(UserCreationForm.Meta):
model = User
UserCreationForm.Meta.fields = ('email',)
fields = UserCreationForm.Meta.fields + ('full_name','role', 'notify', 'provider', 'email_verified', 'company', 'is_active', 'is_staff')
UserCreationForm.Meta.fields = ('password1','password2',)
class CustomUserChangeForm(UserChangeForm):
class Meta(UserChangeForm.Meta):
model = User
UserChangeForm.Meta.fields = ('email',)
fields = UserChangeForm.Meta.fields + ('full_name','role', 'notify', 'provider', 'email_verified', 'company', 'is_active', 'is_staff')
UserChangeForm.Meta.fields = ('password1','password2',)