'TypeError: 'BasePermissionMetaclass' object is not iterable in django rest framework
i looked at other questions regarding this issue and their problems were in the REST_FRAMEWORK = ... values in settings.py file . is there any error in mine ?
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
 
    'api_basic',# this is my app that uses authtokens
    'rest_framework',
    'rest_framework.authtoken',
]
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
    ],
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],
}
view:
@api_view(['GET', ])
@permission_classes(IsAuthenticated)
def api_hero(request, name):
    try:
        character = Hero.objects.get(name=name)
    except:
        return Response(status=status.HTTP_404_NOT_FOUND)
    serializer = serializers.HeroSerializer(character)
    return Response(serializer.data)
							
						Solution 1:[1]
so i found the answer my self . the problem was in view
@permission_classes(IsAuthenticated) 
here permission classes arguments should be a tuple.
so:
@permission_classes((IsAuthenticated,)) 
is the way to go.
Solution 2:[2]
 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.AllowAny',)
Add the following line to your settings.py.
It turns out omitting the last comma from the tuple will throw an error because 'DEFAULT_PERMISSION_CLASSES' expects a tuple
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | TonyMontana | 
| Solution 2 | Samuel Tosan Ayo | 
