[Fixed]-Django current user is AnonymousUser

1👍

You are close.

in settings.py:

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    )
}

in views.py:

from rest_framework.permissions import IsAuthenticated

class ChartData(APIView):
    authentication_classes = []
    permission_classes = [IsAuthenticated, ]

get(self, request, format=None):
    ...

Leave a comment