[Django]-How to add TokenAuthentication authentication classes to Django FBV

7👍

A special thanks to @JPG and @invincibly cool without which I could not have gotten this done below is the code

from rest_framework.decorators import authentication_classes
from rest_framework.authentication import TokenAuthentication
from rest_framework.decorators import api_view
from rest_framework.decorators import permission_classes
from rest_framework.permissions import IsAuthenticated


@api_view(http_method_names=['GET'])
@authentication_classes((TokenAuthentication,))
@permission_classes((IsAuthenticated,))
def some_function(request, pk):
    #code below

Leave a comment