user9469766
user9469766

Reputation:

Django Rest Framework: Set Permissions for function view

The default permissions requires token authentication. I have a function based view that has the api_view decorator. How can I explicitly set its permissions to not require authentication and csrf exempt?

@api_view(['GET'])
def activate(request, uidb64, token):
    ....

Upvotes: 3

Views: 1926

Answers (1)

Arjun Shahi
Arjun Shahi

Reputation: 7330

You can use the permission_classes decorator like this:

  @api_view(['GET'])
  @permission_classes((IsAuthenticated, ))
  def activate(request, uidb64, token):
....

Upvotes: 8

Related Questions