本文整理汇总了Python中forms.ChangePasswordForm.change_password方法的典型用法代码示例。如果您正苦于以下问题:Python ChangePasswordForm.change_password方法的具体用法?Python ChangePasswordForm.change_password怎么用?Python ChangePasswordForm.change_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.ChangePasswordForm
的用法示例。
在下文中一共展示了ChangePasswordForm.change_password方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: password_change
# 需要导入模块: from forms import ChangePasswordForm [as 别名]
# 或者: from forms.ChangePasswordForm import change_password [as 别名]
def password_change(request):
"""
A view for changing a password
"""
if request.method == 'POST':
form = ChangePasswordForm(request.POST)
if form.is_valid():
email = form.cleaned_data.get('email')
if email == '[email protected]':
msg = 'The demo user cannot change the password'
messages.error(request, msg)
else:
# change the password
form.change_password(request.user)
# re-direct to information message
msg = """
Your password was successfully changed!
"""
messages.success(request, msg)
else:
form = ChangePasswordForm()
return render_to_response('account/password_change.html',
{ 'form' : form },
context_instance=RequestContext(request))