Reputation: 6779
When I click on activation link http://127.0.0.1:8000/core/auth/activate/aoisdoaisdoaisdoiaj/
I am taken to an activation_failed page which says - The activation key you provided is invalid
.
But my account in the database gets activated too.
If the account is being activated that means activation was successful, then why would django-registration redirect to failed page? Thanks
Upvotes: 0
Views: 333
Reputation: 1947
You are being redirected to activation/complete/
and your custom activation URL is catching this URL. To restore the built in behavior, add a URL pattern above your custom activation URL like so:
path("activate/complete/",
TemplateView.as_view(template_name="django_registration/activation_complete.html"),
name="django_registration_activation_complete")
Upvotes: 0
Reputation: 6779
There are 2 urls in django-registration/backends/activation/urls.py that create complications which is hard to figure out for a django rookie like myself : Lets call them url1 and url2 as per order shown below.
"activate/complete/"
"activate/<str:activation_key>/"
They are strategically ordered in original urls.py. But since I overwrote ActivationView class, I had to overwrite the url2 "activate/<str:activation_key>/"
. That changed the original order and django started looking for url2 before url1. As you can see that any url of format /activate/xyz/
can qualify as url2. Hence /activate/complete/ also called view in url2.
Solution: change name of url1 to something like activation/complete/
and it all works fine
That put
Upvotes: 1