[Django]-The `request` argument must be an instance of `django.http.HttpRequest`, not `builtins.str`

2👍

The problem is that you are decorating the class with @permission_classes((permissions.AllowAny,)) and this generates some string and it is goes through your API class that expects django.http.HttpRequest

the usage of permission on APIView is:

from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView

class ExampleView(APIView):
    permission_classes = [IsAuthenticated]

    def get(self, request, format=None):
        content = {
            'status': 'request was permitted'
        }
        return Response(content)

from drf documentation

1👍

If you could add all code referenced above that would help. This has happened to me when trying to do async tasks in Django

👤merhoo

Leave a comment