Issue
This Content is from Stack Overflow. Question asked by Mustansir Godhrawala
Django allauth fails when using a custom user model with the email as the primary key, I learnt about this when I tried to test the password change functionality.
Reverse for 'account_reset_password_from_key' with keyword arguments '{'uidb36': 'mgodhrawala402@gmail.com', 'key': 'bbz25w-9c6941d5cb69a49883f15bc8e076f504'}' not found. 1 pattern(s) tried: ['accounts/password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$']
I don’t mind going into the code to fix this issue, since my application is still under development, I can still change authentication incase anyone has any suggestions.
Solution
The easiest fix for this problem would be adding a sequence integer pk and just updating your email field to index unique because as you see the regex path doesn’t accept email format for uidb36
, it only accepts 0-9A-Za-z
.
If you must use email as pk you can add another path to your urls to accept your email pattern:
from allauth.account import views
path('accounts/', include('allauth.urls')),
re_path(
r"^accounts/password/reset/key/(?P<uidb36>.+)-(?P<key>.+)/$",
views.password_reset_from_key,
name="account_reset_password_from_key_accept_email",
),
This Question was asked in StackOverflow by Mustansir Godhrawala and Answered by Đào Minh Hạt It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.