I have a viewset
subclassing from modelviewset
, I add next:
authication_classes = [SessionAuthentication,BasicAuthentication]
permission_classes = [IsAuthenticated]
Then, got following message when list, detail/retrieve and put requests.
"detail": "Authentication credentials were not provided."
What should i change to only give this message when I update the data ??
Override get_permissions
method on the ModelViewSet
class.
Example:
class FooViewSet(ModelViewSet):
authentication_classes = (SessionAuthentication, BasicAuthentication, )
permission_classes = (IsAuthenticated, )
def get_permissions(self):
if self.request.method != 'PUT':
return []
return super().get_permissions()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With