Сделать вызов patch () из drf - PullRequest
0 голосов
/ 12 ноября 2018
class UserProfile(viewsets.ModelViewSet):
    .......
    .......
    #some codes here
    .......

@csrf_exempt
def change_user_password(self, request):
    #some actions here 
    if(condition):
       UserProfile.patch(request)
    ..........
    return ...

Здесь я привел пример кода, который может не работать. Но все, что мне нужно, это сделать вызов патча для UserProfile класса viewset из функции change_user_password

1 Ответ

0 голосов
/ 12 ноября 2018

Вы близки, вам просто нужно сделать объект UserProfile, см. Редактирование примера кода:

class UserProfile(viewsets.ModelViewSet):
    .......
    .......
    #some codes here
    .......

def change_user_password(self, request):
    #some actions here 
    if(condition):
       user_profile_obj = UserProfile()
       user_profile_obj.patch(request)
    ..........
    return ...
...