Django REST Framework: 'BasePermissionMetaclass' object is not iterable
As a reference for other people who might be searching here, this could be an issue too..
from django.contrib.auth.models import User
from rest_framework.generics import UpdateAPIView
from .serializers import UserSerializer
class UpdateView(UpdateAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
permission_classes = IsAuthenticated
Should change to:
from django.contrib.auth.models import User
from rest_framework.generics import UpdateAPIView
from .serializers import UserSerializer
class UpdateView(UpdateAPIView):
queryset = User.objects.all()
serializer_class = UserSerializer
permission_classes = [IsAuthenticated]
You have mistyped the comma in DEFAULT_PERMISSION_CLASSES
value, due to which Django takes it as a string, instead of a tuple.
Solution:
REST_FRAMEWORK = {
...
'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAdminUser', ),
...
}
I had the same problem, but looked for wrong place. I made mixin class with permissions and there was code
permission_classes = (
permissions.IsAuthenticated
)
but should be
permission_classes = (
permissions.IsAuthenticated,
# ^
# a comma here
)
So do not forget to look for other classes with permissions. I hope it will help someone.