OneBite.Dev - Coding blog in a bite size

Access route without authentication in Django rest framework

How to access a route without authentication in Django rest framework, when the best setting has DEFAULT_PERMISSION_CLASSES

How to access a route without authentication in Django rest framework, when the best setting has DEFAULT_PERMISSION_CLASSES.

If your base setting has this

"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),

And want to access a route on same app or new app, you can add permission_classes to the Class View with value Allow any , which means no authentication need

class TestView(RetrieveAPIView):
  permission_classes = [AllowAny]
  ...
django-rest-framework