Как сбросить пароль с помощью html-шаблона в django djoser

Я создал основанный на классах вид rest api. где я использовал django djoser. Мой шаблон активации и все ссылки работают. но сейчас я работаю над сбросом пароля, где я использовал шаблон для сброса пароля. но выдает 405 ошибку. Я получил ссылку на сброс пароля. также моя html страница работает, но когда я изменил свой пароль и нажал на submit, она выдает 405 ошибку

views.py

class ResetPasswordView(View):
      def get (self, request, uid, token):
        return render(request, 'password_reset_email.html') # display activation page when user click on link which recieved fron gmail

    def post (self, request,uid,token):
        print('In Password Reset Post')
        new_password=request.post.get("new_password")
        print("new_password :",new_password)
        re_new_password=request.post.get("re_new_password")
        print("re_new_password : ",re_new_password)
        payload = json.dump({'uid': uid, 'token': token, 'new_password': new_password, 're_new_password': re_new_password})
        protocol = 'https://' if request.is_secure() else 'http://'  # will evaluate to True if the connection is secure (HTTPS: HTTP over TLS) or False if non-secure (standard HTTP).
        web_url = protocol + request.get_host() + '/'
        password_reset_url = "users/reset_password_confirm/" # url used for activate user
        password_post_url = web_url + AUTHENTICATION_BASE_ROUTE + password_reset_url # for activate user
        print('url : ', password_post_url)
        response = request.post(password_post_url,data=payload)
        return HttpResponse(response.text)

urls.py

    re_path(r'^password/reset/confirm/(?P<uid>[\w-]+)/(?P<token>[\w-]+)/$', ResetPasswordView.as_view()),

password_reset_email.html

<form action="" method="post">
                      {% csrf_token %}
                      {{ form.as_p}}
                      <div class="container">
                        <h1>Register</h1>
                        <p>Please fill this form to create an account.</p>
                        <hr>
                        <label for="psw"><b>New Password</b></label>
                        <input type="password" placeholder="Enter Password" name="new_password" id="new_password" required>

                        <label for="psw-repeat"><b>Repeat Password</b></label>
                        <input type="password" placeholder="Repeat Password" name="re_new_password" id="re_new_password"
                          required>
                        <hr>

                        <button type="submit" class="registerbtn">Register</button>
                      </div>

                    </form>

settings.py

DJOSER = {
# 'activation': 'user_profile.email.ActivationEmail',
'LOGIN_FIELD': 'email',
'USER_CREATE_PASSWORD_RETYPE': True,
'USERNAME_CHANGED_EMAIL_CONFIRMATION': True,
'PASSWORD_CHANGED_EMAIL_CONFIRMATION': True,
'SEND_CONFIRMATION_EMAIL': True,
'SET_USERNAME_RETYPE': True,
'SET_PASSWORD_RETYPE': True,
'PASSWORD_RESET_CONFIRM_URL': 'password/reset/confirm/{uid}/{token}',
'USERNAME_RESET_CONFIRM_URL': 'email/reset/confirm/{uid}/{token}',
'ACTIVATION_URL': 'activate/{uid}/{token}',
'SEND_ACTIVATION_EMAIL': True,
'EMAIL':
{
    'activation': 'user_profile.email.ActivationEmail',
    'conformation_email':'user_profile.email.ConfirmationEmail',
    'password_reset_email':'user_profile.email.PasswordResetEmail',
    'PasswordChangedConfirmationEmail':'user_profile.email.PasswordChangedConfirmationEmail'

},
'SERIALIZERS': {
    'user_create': 'user_profile.serializer.UserSerializer',
    'user': 'user_profile.serializer.UserSerializer',
}

}

AUTHENTICATION_BASE_ROUTE = 'authentication/v2/'

Я получал ссылку на сброс пароля. также моя html страница работает, но когда я изменил пароль и нажал на submit, она выдала мне 405 ошибку

Вернуться на верх