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)