我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用django.contrib.auth.views.password_reset()。
def get(self, request, *args, **kwargs): # Seo seo = Seo() seo.title = _('Password reset') seo.save(request) if request.user.is_authenticated(): # ????? ?????? ??????, ???? ???????????? form = SetPasswordForm(request.user) return self.render_to_response({ 'form': form, 'target': resolve_url('users:reset_self'), }) else: return password_reset(request, template_name='users/reset.html', password_reset_form=PasswordResetForm, )
def post(request): email = request.POST.get('email', '') request.session['reset_email'] = email # Seo seo = Seo() seo.title = _('Password reset') seo.save(request) return password_reset(request, template_name='users/reset.html', password_reset_form=PasswordResetForm, post_reset_redirect='users:reset_done', email_template_name='users/emails/reset_email.html', html_email_template_name='users/emails/reset_email.html', subject_template_name='users/emails/reset_subject.html', )
def forgot_passwd(request): """ User password reset page. """ dc_settings = request.dc.settings return password_reset( request, template_name='gui/accounts/forgot.html', email_template_name='gui/accounts/forgot_email.txt', subject_template_name='gui/accounts/forgot_subject.txt', password_reset_form=partial(ForgotForm, request), post_reset_redirect=reverse('forgot_done'), from_email=dc_settings.DEFAULT_FROM_EMAIL, current_app='gui', extra_context={ 'e_site_name': dc_settings.SITE_NAME, 'e_site_link': dc_settings.SITE_LINK, })
def get(self, request): from django.conf import settings return password_reset(request, 'registration/password_reset_form.html')
def post(self, request): email = request.POST['email'] # NOTE this does not provide the email address yet, since it seems like there # is a bug in django (at least imo). The path with HttpResponseRedirect omits the extra_context-field # s.a. http://python.6.x6.nabble.com/Django-24944-Have-password-reset-pass-extra- # context-to-the-email-template-rendering-as-well-td5097076.html # TODO did I mean url instead of email address? return password_reset(request, template_name='registration/password_reset_form.html', post_reset_redirect='password_reset_done', extra_context={'email': email}) # TODO BUG does it work as intended again?