[Django]-TypeError: get() takes 1 positional argument but 2 were given

3👍

The .get(…) method [Django-doc] takes a request parameter as well, even if you do not use it, so:

class UserDetails(APIView):

    # …

    def get(self, request):
        # …
        pass

I would strongly advise, not to make token a global variable. The same webserver can be used for another user that thus has not authenticated (properly). Take a look at the Authentication section of the Django REST framework documentation for more information on how to authenticate and check credentials.


Note: In Django, class-based views (CBV) often have a …View suffix, to avoid a clash with the model names.
Therefore you might consider renaming the view class to UserDetailsView, instead of UserDetails.

Leave a comment