If you are new to Django

March 13, 2018, 4:45 p.m.

Hi friends,

It's important to give back to the community especially if you learn from it. I use information in the Internet in my studying a lot. So here is a tip if you are struggling with making you Django app work.

In my Django app I used "Django REST framework". In myApp's Authentication "request.user" always returned Anonymous user.
I have function based views. And the fix was to use @api_view decorator. Like this:

@api_view(['GET', 'POST'])
def example_view(request, format=None):
if request.method == "POST" and request.user:
...

Hope it's gonna help to fix your app!