Closed
Description
Hi All,
I am trying to restrict TokenAuthentication to some methods( in this case to my_method in the below snippet) in the ViewSets. Below is the snippet of code,
class MyViewSet(ViewSet):
def get_authenticators(self):
if self.action == 'my_method':
return [TokenAuthentication()]
return []
def my_method(self, request, *args, **kwargs):
< rest of logic goes here >
But I get the error saying , MyViewSet has no attribute action.
Am I doing it in a wrong way? or this is not available in the ViewSet.
Please let me know the correct way to achieve this.
Metadata
Metadata
Assignees
Labels
No labels