I'm trying to recover a GET
parameter from the django template view django.contrib.auth.PasswordResetConfirmView
. Basically when a user click on his password reset link (like http://127.0.0.1:8000/commons/reset/MQ/4t8-210d1909d621e8b4c68e/?origin_page=/mypage/
) I want to be able to retrieve the origin_page=/mypage/
argument. So far my url.py
looks like this:
from django.urls import path
from . import views
app_name = 'commons'
urlpatterns = [
path('reset/<uidb64>/<token>/', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
]
And my views.py
like this:
from django.contrib.auth import views as auth_views
class PasswordResetConfirmView(auth_views.PasswordResetConfirmView):
template_name = 'commons/password_reset_confirm.html'
success_url = '/commons/reset/done/'
def get(self, request, *args, **kwargs):
self.extra_context = {
'origin_page': self.request.GET['origin_page']
}
return super().get(request, *args, **kwargs)
As you can see I'm trying to get my origin_page
with 'origin_page': self.request.GET['origin_page']
but it doesn't work. It throws me a MultiValueDictKeyError
. I even used the debugger to inspect every objects from the class/method but none of them seems to contains my origin_page
variable. Any idea? Thanks
Aucun commentaire:
Enregistrer un commentaire