From 372ba5a0f2349402db2172af26ced67176bfff56 Mon Sep 17 00:00:00 2001 From: catborise Date: Fri, 21 Aug 2020 20:53:16 +0300 Subject: [PATCH] fix create user error --- admin/forms.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/admin/forms.py b/admin/forms.py index 6856d7b..72e6d0a 100644 --- a/admin/forms.py +++ b/admin/forms.py @@ -73,13 +73,14 @@ class UserForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(UserForm, self).__init__(*args, **kwargs) - password = ReadOnlyPasswordHashField(label=_("Password"), - help_text=format_lazy(_("""Raw passwords are not stored, so there is no way to see - this user's password, but you can change the password - using this form."""), - reverse_lazy('admin:user_update_password', args=[self.instance.id,])) - ) - self.fields['Password'] = password + if self.instance.id: + password = ReadOnlyPasswordHashField(label=_("Password"), + help_text=format_lazy(_("""Raw passwords are not stored, so there is no way to see + this user's password, but you can change the password + using this form."""), + reverse_lazy('admin:user_update_password', args=[self.instance.id,])) + ) + self.fields['Password'] = password class UserCreateForm(UserForm):