'Append key/value to a request in a before call another view with the same request on DRF

I've a drf view with a signup that takes:

{ 
"github": "",
 ...
"user": {
   "username": "john", "password": "pass"
   }
}

ok, now I need to build a new endpoint that will accept no password:

{ 
"github": "",
 ...
"user": {
   "username": "john"
   }
}

The password is required, the serializer is much more bigger and complex. I've created a view like this:

@api_view(["POST"])
def add_user_no_pass(request):
    request_data = copy.deepcopy(request._request)
    request_data.get("user").update({"password": "12345"})
    return SignUp.as_view()(request_data)

I've try a lot of things, that was my last try, basically I just need to add password to the user in the request before forward to the next view, I'm using drf. Thanks.

tried to add the password in many ways to the request. But drf request is a little different from django.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source