I build an API with django and I'm automating the welcome email at creation of one user with Sendinblue. I have no problem at this step. (so we are at the url /add_user/
)
I have a second url to send a link (uid + token) to a user (thanks to his email). For that I use an external package : djoser. So I use the url of djoser /auth/users/reset_password/
and /auth/users/reset_password_confirm/
My dream would be to combine /reset_password/
and /add_user/
in the single url /add_user/
My problem is that the logic in /reset_password/
and /reset_password_confirm/
was written by djoser so I can't handle it. Or I don't know how !
Here is what I tried to override djoser views :
in urls.py:
path('custom_djoser/', ChangeCredentialsView.as_view(), name='customdjoser'),
in views.py:
class ChangeCredentialsView(UserViewSet):
def post(self, *args, **kwargs):
print("hello world")
return JsonResponse({"helloworld":"success"})
got the following error :
The actions argument must be provided when calling .as_view() on a ViewSet. For example .as_view({'get': 'list'})
So I removed the .as_view() in urls.py and got this error :
Forbidden (CSRF token missing or incorrect.): /custom_djoser/
For me its incomprehensible because I don't use csrf token, but I tried with @csrf_exempt in a dispatch function inside my class. I tried to define class ChangeCredentialsView(UserViewSet, APIView):
as my other class with authorization token. Nothing to do, everytime error with csrf token.
I may explore a really painful and stupid way to do what I want to do, please tell me if there is an easier way to do this !