如何解决在默认泛型UpdateAPIView中使用部分更新
是否可以在我的默认UpdateAPIView中包含poth更新和部分更新,而无需编写额外的PartialUpdate视图。我让用户更新其个人资料页面,并使用axios.put发送数据,并且我也希望仅在更改一个字段时进行更新。有可能吗,我该如何实现?
我的ProfileViewUpdate:
class ProfileViewUpdate(generics.UpdateAPIView):
queryset = Profile.objects.all()
serializer_class = ProfileSerializer
lookup_field = 'token'
lookup_url_kwarg = 'pk'
我的axios.put方法从表单获取数据并将其发送到API:
axios.put(`http://127.0.0.1:8000/api/profile/${profileID}/update`,{
name: name,email: email,location: location,sport: sport,image: image,})
.then(res => console.log(res))
.catch(error => console.err(error));
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。