PasswordResetView: context variable protocol return http instead of https

117 Views Asked by At

I use Django registration module in one of my app stack : django/postgresql/docker

I override password reset view:

class ResetPasswordView(SuccessMessageMixin, PasswordResetView):

    template_name = 'registration/password_reset_form.html'
    email_template_name = 'registration/password_reset_email.html'
    subject_template_name = 'registration/password_reset_subject.txt'
    success_message = "We've emailed you instructions for setting your password, " \
                      "if an account exists with the email you entered. You should receive them shortly." \
                      " If you don't receive an email, " \
                      "please make sure you've entered the address you registered with, and check your spam folder."
    success_url = reverse_lazy('home')

and following template for reset password:

Someone asked for password reset for email {{ email }}. 
Follow the link below:
{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}

PS : Please do not reply to this email

but email template context protocol return http instead of https

what's wrong?

1

There are 1 best solutions below

0
Lorenzo Prodon On

You can build your url inside the View, in the get_context_data() method and use request.build_absolute_uri()