Django REST Framework - Custom Permissions not Evaluating -


i'm trying set custom permissions on class extends viewsets.modelviewset , appears permissions not being evaluated. here view:

from rest_framework import viewsets rest_framework.authentication import sessionauthentication, basicauthentication rest_framework.permissions import isauthenticated  import models import serializers permissions import isadminorauthenticatedreadonly  class kpiviewset(viewsets.modelviewset):     '''     api endpoint allows kpi metadata viewed or edited     '''      authentication_classes = (basicauthentication,)     permission_classes = (isadminorauthenticatedreadonly,)      queryset = models.kpi.objects.all()     serializer_class = serializers.kpiserializer 

and here permission class:

from rest_framework.permissions import basepermission, safe_methods  class isadminorauthenticatedreadonly(basepermission):     def has_permissions(self, request, view):          if request.method in safe_methods:             return request.user , request.user.is_authenticated()          return request.user , request.user.is_staff() 

the problem i'm running isadminorauthenticatedreadonly never seems evaluated. tested both forcing return "false" , switching permission_classes value "isauthenticated" in view. in former scenario, request endpoint returns if there no authentication requirement. in later, authentication enforced expected.

any ideas i'm missing?

the method name has_permission not has_permissions (no s) ;)


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -