class UserProfile(viewsets.ModelViewSet):
.......
.......
#some codes here
.......
@csrf_exempt
def change_user_password(self, request):
#some actions here
if(condition):
UserProfile.patch(request)
..........
return ...这里我给出了一个可能无法运行的示例代码。但我所需要的只是从change_user_password函数对UserProfile视图集类进行补丁调用
发布于 2018-11-12 19:51:28
你已经很接近了,你只需要创建一个UserProfile的对象,请看示例代码的编辑:
class UserProfile(viewsets.ModelViewSet):
.......
.......
#some code here
.......
def change_user_password(self, request):
#some action here
if(condition):
user_profile_obj = UserProfile()
user_profile_obj.patch(request)
..........
return responsehttps://stackoverflow.com/questions/53261022
复制相似问题