Забыли пароль Django - password_reset (пользовательская модель пользователя)
ищу помощи. Я начинающий разработчик Python/Django.
У меня есть следующий вид:
class UserForgotPasswordView(auth_views.PasswordResetView):
with open(str(settings.BASE_DIR) + "/frontend/static/frontend/languages/emails/EN/email_footer__main.json", "r") as temp_file_email_footer_main:
email_footer_main_data = json.load(temp_file_email_footer_main)
with open(str(settings.BASE_DIR) + "/frontend/static/frontend/languages/emails/EN/email_user_forgotPassword.json", "r") as temp_file_email_forgot_password:
email_forgot_password_data = json.load(temp_file_email_forgot_password)
extra_email_context = { 'email_footer_static_json_text': email_footer_main_data,
'email_static_json_text': email_forgot_password_data,
'static_json_text': static_textLanguage,
'static_json_textGlobal': static_textGlobal}
html_email_template_name = '../frontend/templates/frontend/templates.emails/template.email_user_forgotPassword.html'
from_email = 'numeratio <support@numeratio.com>'
title = 'numeratio password reset'
subject_template_name = 'registration/password_reset_subject.txt'
template_name = '../frontend/templates/frontend/templates.user/template.page_forgotPassword.html'
success_url = reverse_lazy('password_reset_done')
def get(self, request, *args, **kwargs):
context = super().get_context_data(**kwargs)
try:
if not self.request.user.is_authenticated:
context = { 'email_subject': self.email_forgot_password_data['emailSubject'],
'static_json_text': static_textLanguage,
'static_json_textGlobal': static_textGlobal}
return self.render_to_response(context)
except:
if self.request.user.is_authenticated:
return HttpResponseRedirect(reverse('page_home'))
Я пытаюсь добиться того, что если пользователь аутентифицирован (залогинен), то при попытке перейти по ссылке forgot-password он перенаправляется домой. Шаблон отображается нормально, если пользователь не авторизован/анонимен. Однако я получаю следующую ошибку для авторизованных пользователей, пытающихся получить доступ к странице
The view users.views.UserForgotPasswordView didn't return an HttpResponse object. It returned None instead.
Мне нужна помощь с редиректом. Любая помощь приветствуется.