I have added JWT authentication in my django react project. what i want to achieve that i want to expose some api without authentication. its a ecommerce project and i want to expose category listing api so that anyone can access without authentication.
settings.py:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES':[
#'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
'rest_framework_simplejwt.authentication.JWTAuthentication',
#'rest_framework.authentication.SessionAuthentication',
# 'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES':[
'rest_framework.permissions.IsAuthenticated',
#'rest_framework.permissions.AllowAny',
],
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE':10,
}
views.py:
@permission_classes((IsAuthenticated,))
class UserViewSet(viewsets.ModelViewSet):
queryset = CustomUser.objects.all()
serializer_class = serializers.UserSerializer
#User Registration View
class CreateUserView(generics.CreateAPIView):
model = get_user_model()
permission_classes = [
permissions.AllowAny
]
serializer_class = serializers.RegisterSerializer
#Category Listing View
@permission_classes((IsAuthenticated,))
class CategoryView(generics.ListCreateAPIView):
queryset = Category.objects.all()
serializer_class = CategorySerializers
class CategoryDetailView(generics.RetrieveUpdateAPIView):
queryset = Category.objects.all()
serializer_class = CategorySerializers
also want to remove pagination from category listing