title: Authentication in Django rest framework function based views
body: <p>So i have a function based view in my Django rest framework and i do authentication in it as follows:</p>
  
  <pre><code>from rest_framework import status
  from rest_framework.decorators import api_view
  from rest_framework.response import Response
  
  @api_view(['GET'])
  def analytics_filter_values(request):
      if request.user.is_authenticated():
          pass
      else:
          return Response("Unauthorized access", status=status.HTTP_403_FORBIDDEN)
  .....
  &lt;business logic&gt;
  .....
  .....
  </code></pre>
  
  <p>Now in this view file,I have quite a few views and inside each function,i use the if else to check the authentication.So in order to reduce the lines of code,i decided to make this a function and then call it inside each function view as follows :</p>
  
  <pre><code>from rest_framework import status
  from rest_framework.decorators import api_view
  from rest_framework.response import Response
  
  def check_authentication(request):
  if request.user.is_authenticated():
      pass
  else:
      return Response("Unauthorized access", status=status.HTTP_403_FORBIDDEN)
  
  @api_view(['GET'])
  def analytics_filter_values(request):
      check_authentication(request)
  .....
  &lt;business logic&gt;
  .....
  .....
  </code></pre>
  
  <p>However,this does not work.This could be really silly but i am clueless as to what is amiss here..</p>