In Django's auth contrib module, how do I correctly return an error when overriding the asswordResetConfirmView view?

I'm using Django 3 and the auth contrib module. I want to override the reset password procedure via an API and so I have a method that looks like this ....

class CompleteResetPasswordView(PasswordResetConfirmView):

    @method_decorator(csrf_exempt)
    def dispatch(self, request):
        body = json.loads(request.body)
        self.data = body

        # validate user, password, and confirm password
        if user is not None:
            ...
                    return Response('Success', status=HTTP_200_OK)
        ...
        return Response('Error', status=HTTP_500_INTERNAL_SERVER_ERROR)

When the user cannot be validated and the "return Response('Error', status=HTTP_500_INTERNAL_SERVER_ERROR)" is invoked, this error is returned

AssertionError at /password-reset-complete
.accepted_renderer not set on Response

I would liek a JSON response (in addition to the 500 status code) to be returned to the view, but haven't figured out how to manipulate what I have to make this happen.

Back to Top