title: Authentication in Django during GET request
body: <p>I need to do a GET request to my Django server through an android application.
  The problem is that this GET function is written in Django with a @login_required.</p>
  
  <p>What kind of request should i do to login and perform the GET request?</p>
  
  <p>My API:</p>
  
  <pre><code>from django.shortcuts import render
  from django.http import HttpResponse,HttpResponseServerError, HttpResponseBadRequest
  from rest_framework.decorators import api_view
  from .models import Order, New
  import json
  from django.shortcuts import render_to_response
  from .forms import NewForm
  from django.core.files.storage import FileSystemStorage
  from django.contrib.auth.decorators import login_required
  from .validation import *
  from django.views.decorators.csrf import csrf_exempt
  @login_required
  @api_view(['GET'])
  def get_order(request):
  
      order_list = Order.objects.values("user_name",
                          "user_surname",
                          "order_date").all()
  
      return HttpResponse(json.dumps([x for x in order_list])
  </code></pre>
  
  <p>My urls.py:</p>
  
  <pre><code>from django.urls import path
  from django.conf.urls import url
  from . import views
  
  app_name = 'API'
  urlpatterns = [
      url(r'^$', views.index, name='index'),
      url(r'^order', views.order, name='order'),
      url(r'^get_order', views.get_order, name='get_order')]
  </code></pre>
  
  <p>and: </p>
  
  <pre><code>from django.contrib import admin
  from . import settings
  from django.views.static import serve
  from django.urls import path, include, re_path
  from django.conf.urls.static import static
  from API.views import index
  
  urlpatterns = [
      path('API/', include('API.urls',namespace="API")),
      path('admin/', admin.site.urls),
      path('', index, name='index'),
      path(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
      re_path(r'^media/(?P&lt;path&gt;.*)$', serve, {'document_root': settings.MEDIA_ROOT})
  ]
  </code></pre>
  
  <p>In Postman i'm performing a GET (<a href="http://127.0.0.1:8000/API/get_order" rel="nofollow noreferrer">http://127.0.0.1:8000/API/get_order</a>) with basic auth, receiving <code>302</code> status code.</p>