0

How to call the custom function in update function, my views is this-

class StokeBulkUpdate(generics.APIView):
 ......
    def custom_function(list):
        return list

    def update(self, request,*args,**kwargs):
        data = self.request.data
        custom_function

1 Answer 1

1

The custom function is a property of the class, which can be accessed via self:

class StokeBulkUpdate(generics.APIView):

   def custom_function(self, list):
       return list

   def update(self, request,*args,**kwargs):
       data = self.request.data
       self.custom_function(data)

If you don't want to implicitly pass self to your method (like in your example), you need to use @staticmethod:

class StokeBulkUpdate(generics.APIView):

   @staticmethod
   def custom_function(list):
       return list

   def update(self, request,*args,**kwargs):
       data = self.request.data
       self.custom_function(data)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.