I\'m developing an API using Django Rest Framework. I\'m trying to list or create an \"Order\" object, but when i\'m trying to access the console gives me this error:
<
I too faced the same since I missed adding
authentication_classes = (TokenAuthentication)
in my API view class.
class ServiceList(generics.ListCreateAPIView):
authentication_classes = (SessionAuthentication, BasicAuthentication, TokenAuthentication)
queryset = Service.objects.all()
serializer_class = ServiceSerializer
permission_classes = (IsAdminOrReadOnly,)
In addition to the above, we need to explicitly tell Django about the Authentication in settings.py file.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
)
}