I set basic authentication in my setting.py as follows. Now I need a view that doesn't use basic authentication. How can I do it.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',),
}
You simply need to set the authentication_classes
on your view. Have a look at http://www.django-rest-framework.org/api-guide/authentication/#setting-the-authentication-scheme for an example.
Edit:
To remove authentication, set the authentication_classes
to an empty list. Don't forget to remove permissions as well since they usually rely on authentication.
To exclude a view from authentication, set authentication_classes
and permission_classes
to []
.
class SignupView(APIView):
authentication_classes = []
permission_classes = []
def post(self, request):
# view code