Question:I am building and Inventory Web App and I am facing this error. I am trying to get Username from token to show a custom hello message and show that the user is logged in as someone.
Here is my Views.py that gets Token from localStorage as logged in user:
Here is my Urls.py:
And this is the error that I get:
.get(…)method [Django-doc] takes a
requestparameter as well, even if you do not use it, so:
tokena 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.
If you have better answer, please add a comment about this, thank you!