5👍
Try editing your view like this,
class UserUpdateAPIView(generics.RetrieveUpdateAPIView):
permission_classes = (permissions.IsAdminUser,)
serializer_class = UserUpdateSerialier
lookup_field = 'username'
def get_object(self):
username = self.kwargs["username"]
return get_object_or_404(User, username=username)
def put(self, request, *args, **kwargs):
return self.update(request, *args, **kwargs)
2👍
You need to set lookup_field = 'username'
to the UserUpdateAPIView
just like you did with the UserDetailAPIView
- [Django]-Can not assign None to Django DateTimeField()
- [Django]-Django ORM – No cascading deletion of a many-to-many relationship
- [Django]-WSGIRequest object has no attribute PUT
- [Django]-Errors 404 and 500 while access static files in Django
- [Django]-ModuleNotFoundError : no module named : crispy_forms
Source:stackexchange.com