Customized Password Reset URL for Django Rest API Password Reset

Viewed 72

I am new to Django and have implemented a password reset endpoint for my rest API using the django-rest-passwordreset library. It works fantastic, but I want to customize the url returned in my email to include "https://" and domain name before the path and token so that the full URL is shown in the email.

As of now, the email send me a path like this:

/password-reset/?token=random_string_of_characters_are_here

I'd like it to email me something like this:

https://mywebsite.com/password-reset/?token=random_string_of_characters_are_here

1 Answers

what i do is add the url in context :

from django.conf import settings

context.update({"FRONT_URL": settings.FRONT_URL})
content = render_to_string("emails/reset.html".format(template), context)

I populate FRONT_URL in settings.py and i can use {{ FRONT_URL }} in my template.

I use context.update so i can just add FRONT_URL to other context values

Related