Public Endpoint in Django Rest Framework

Disable Authentication in Django REST Framework for a single or multiple APIView classes.


Django Rest Framework packs with a bundle of handy permission and authentication classes to allot different permissions depending on day to day needs. But it lacks a permission to bypass the existing permission and go over without an authentication and make an open endpoint.

The is not a requirement in a typical application but I needed an open api endpoint to transfer status to a different application and all other views require authentication.

Django uses permission class to check if the user requesting has permission to the view. Permission classes uses authenticated data returned from authentication class (which authenticates user using credentials and then by session or Token) to run over the list of permissions and decided whether or not to allow the request to pass.

To make a view accessible to anonymous user you need to set the permission classes to null.

Class based view

class PublicEndpoint(APIView):

 permission_classes = []

 def get(self, request):
  return Response({'Public Endpoint'})

Functional View

from rest_framework.decorators import authentication_classes, permission_classes

def items(request):
   return Response({'Public Endpoint'})


Wow ! you have someting to tell us. That's great! Please keep in mind that comments are moderated, we employ rel="nofollow" for links, avoid using a spammy word or a domain in name field, it might end up as a Spam. Thanks for reading.

Last 5 Articles

All Articles >

  1. 9 Ways to Boost the Design of Your Sports Team Website

  2. DevOps Tools

  3. The Best Marketing Apps to Use with Shopify

  4. Tips to Increase Software Development Speed

  5. Mitigating Risks In Custom Software Development


News Letter

Subscribe to our email newsletter for useful tips and valuable resources, sent out every new article release.