From a373875c0d0ef64dab21de37ccc85b92dcb3fb4e Mon Sep 17 00:00:00 2001 From: arthur Date: Thu, 19 May 2016 19:21:56 +0200 Subject: [PATCH] Set return of get_update password_url to default value in UserChangeFrom when no instance --- djadmin2/forms.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/djadmin2/forms.py b/djadmin2/forms.py index a65a0a5..0cb23d2 100644 --- a/djadmin2/forms.py +++ b/djadmin2/forms.py @@ -313,12 +313,12 @@ class Admin2UserChangeForm(UserChangeForm): def __init__(self, *args, **kwargs): super(Admin2UserChangeForm, self).__init__(*args, **kwargs) print(self.fields['password'].help_text) - self.fields['password'].help_text = _("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." % self.get_update_password_url()) + self.fields['password'].help_text = _("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." % self.get_update_password_url()) def get_update_password_url(self): - return reverse_lazy('admin2:password_change', args=[self.instance.pk]) - + if self.instance and self.instance.pk: + return reverse_lazy('admin2:password_change', args=[self.instance.pk]) + return 'password/' + UserCreationForm = floppify_form(UserCreationForm) UserChangeForm = floppify_form(Admin2UserChangeForm)