From 7e23d2c234536c3cb8a7e654354027f5ff398d3a Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 10 Jan 2018 11:31:25 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E5=A4=8D=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=AF=86=E7=A0=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/forms.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/users/forms.py b/apps/users/forms.py index c4f008663..c27bd4378 100644 --- a/apps/users/forms.py +++ b/apps/users/forms.py @@ -29,7 +29,7 @@ class UserCreateUpdateForm(forms.ModelForm): model = User fields = [ 'username', 'name', 'email', 'groups', 'wechat', - 'phone', 'role', 'date_expired', 'comment', 'password' + 'phone', 'role', 'date_expired', 'comment', ] help_texts = { 'username': '* required', @@ -38,13 +38,16 @@ class UserCreateUpdateForm(forms.ModelForm): } widgets = { 'groups': forms.SelectMultiple( - attrs={'class': 'select2', - 'data-placeholder': _('Join user groups')}), + attrs={ + 'class': 'select2', + 'data-placeholder': _('Join user groups') + } + ), } def save(self, commit=True): + password = self.cleaned_data.pop('password') user = super().save(commit=commit) - password = self.cleaned_data.get('password') if password: user.set_password(password) user.save()