I am trying to update a model and I need to get the data I send from the front end so I can update the specific two fields I am trying to update.
Here is the view:
class UpdateUserSettings(generics.UpdateAPIView):
permission_classes = [permissions.IsAuthenticated]
serializer_class = SettingsSerializer
name = 'user-settings'
def get_queryset(self):
id = self.kwargs['pk']
return UserSettings.objects.all().filter(user=id)
def partial_update(request, *args, **kwargs):
breakpoint()
At the breakpoint when I do print(request.data) I get an error:
*** AttributeError: ‘UpdateUserSettings’ object has no attribute ‘data’
How can I see the data I am sending from the front end using a patch request? Here is the request function and the formData will be an email and a username:
axios
.patch("api/v1/users/" + userID + "/settings/update/", formData)
.then((response) => {
console.log(response.data);
});
I cannot do anything if I cannot see the data I send to the backend. I only want to update two fields not all the fields.