本文整理汇总了Python中django.contrib.auth.forms.AdminPasswordChangeForm.get_validation_errors方法的典型用法代码示例。如果您正苦于以下问题:Python AdminPasswordChangeForm.get_validation_errors方法的具体用法?Python AdminPasswordChangeForm.get_validation_errors怎么用?Python AdminPasswordChangeForm.get_validation_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.auth.forms.AdminPasswordChangeForm
的用法示例。
在下文中一共展示了AdminPasswordChangeForm.get_validation_errors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: user_change_password
# 需要导入模块: from django.contrib.auth.forms import AdminPasswordChangeForm [as 别名]
# 或者: from django.contrib.auth.forms.AdminPasswordChangeForm import get_validation_errors [as 别名]
def user_change_password(request, id):
if not request.user.has_perm('auth.change_user'):
raise PermissionDenied
user = get_object_or_404(User, pk=id)
manipulator = AdminPasswordChangeForm(user)
if request.method == 'POST':
new_data = request.POST.copy()
errors = manipulator.get_validation_errors(new_data)
if not errors:
new_user = manipulator.save(new_data)
msg = _('Password changed successfully.')
request.user.message_set.create(message=msg)
return HttpResponseRedirect('..')
else:
errors = new_data = {}
form = oldforms.FormWrapper(manipulator, new_data, errors)
return render_to_response('admin/auth/user/change_password.html', {
'title': _('Change password: %s') % escape(user.username),
'form': form,
'is_popup': '_popup' in request.REQUEST,
'add': True,
'change': False,
'has_delete_permission': False,
'has_change_permission': True,
'has_absolute_url': False,
'first_form_field_id': 'id_password1',
'opts': User._meta,
'original': user,
'show_save': True,
}, context_instance=template.RequestContext(request))