Reputation: 460
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
Upvotes: 0
Views: 287
Reputation: 16032
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)
Upvotes: 1