Issue
I want AllowAny
permission only for the retrieve
function. In my ViewSets.
class PostLanguageViewSet(viewsets.ViewSet):
permission_classes = (permissions.AllowAny,)
permission_classes_per_method = {
"retrieve": permission_classes
}
def retrieve(self, request, post_id=None, post_language_id=None, *args, **kwargs):
...
def destroy(self, request, post_id=None, post_language_id=None, *args, **kwargs):
...
def update(self, request, post_id=None, post_language_id=None, *args, **kwargs):
...
- this method allows all function permission
AllowAny
.
Solution
try this
class PostLanguageViewSet(viewsets.ViewSet):
def get_permissions(self):
if self.request.method == 'GET':
return [permissions.AllowAny()]
else:
return super().get_permissions()
Answered By - gypark
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.