Как мне настроить формат ввода, принимаемый Django auth's PasswordResetView?

Я использую Django 3.1 с Python 3.9. Я использую приложение Django django.contrib.auth для управления моими пользователями. Я хотел бы настроить сброс пароля для своих пользователей, используя Django "PasswordResetView", но не знаю, как настроить его для отправки JSON запроса. Я создал это в своем файле urls.py

path('reset_password/', views.ResetPasswordView.as_view(), name='password_reset'),
path('password-reset-confirm/<uidb64>/<token>/',
     auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'),
     name='password_reset_confirm'),
path('password-reset-complete/',
     auth_views.PasswordResetCompleteView.as_view(template_name='users/password_reset_complete.html'),
     name='password_reset_complete'),

Определите это в моем файле views.py

class ResetPasswordView(SuccessMessageMixin, PasswordResetView):
    template_name = 'users/password_reset.html'
    email_template_name = 'users/password_reset_email.html'
    subject_template_name = 'users/password_reset_subject'
    success_message = "We've emailed you instructions for setting your password, " \
                      "if an account exists with the email you entered. You should receive them shortly." \
                      " If you don't receive an email, " \
                      "please make sure you've entered the address you registered with, and check your spam folder."
    success_url = reverse_lazy('users-home')

и определил их в моем файле settings.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtppro.zohopro.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = str(os.getenv('EMAIL_USER'))
EMAIL_HOST_PASSWORD = str(os.getenv('EMAIL_PASSWORD'))

Однако, когда я отправляю POST-запрос к моей конечной точке с данными

{"username": "myuser@example.com"}

в котором "myemail@example.com" является зарегистрированным пользователем, я получаю ответ

curl: (52) Empty reply from server

Конкретный запрос curl выглядит так, как показано ниже...

curl -v 'http://localhost:8000/reset_password' \
  -H 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'Referer: http://localhost:3000/' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
  -H 'Content-Type: application/json' \
  --data-raw '{"username":"myuser@example.com"}' \
  --compressed

Как настроить, какой ввод будет принимать PasswordResetView?

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