Manually Creating a Password Reset URL in Django AllAuth
Django
2022-10-17 11:24 (3 years ago)

Here's the code to create a password reset URL using Django all_auth.
Handling raw passwords involves a high level of risk, so take utmost care in its operation.
from django.contrib.auth import get_user_model
from django.urls import reverse
from allauth.account.forms import default_token_generator
from allauth.account.utils import user_pk_to_url_str
user = get_user_model().objects.get(id=user_id)
temp_key = default_token_generator.make_token(user)
path = reverse(
"account_reset_password_from_key",
kwargs=dict(uidb36=user_pk_to_url_str(user), key=temp_key),
)
print('https://www.example.com' + path)
Please rate this article (No signup or login required)
Current rating: 1.0 (1)
Related posts
How to Fix Display Issues in Django Admin Inlines After Upgrading to 5.1
Return Login and Redirect Views by Hardcoding Social Account Provider in django-allauth (When Using AWS Cognito, etc.)
After Upgrading to Django 5 and Updating Dependencies, SSL: CERTIFICATE_VERIFY_FAILED Error Occurs When Sending Emails
The "first" and "second" Arguments of assertEqual in Django's Unit Tests are Actually "expected" and "actual"
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.