Reputation: 811
I am using IsAuthenticated permission by default and let's say I do not want to change the default permission. Is it possible to give permission of AllowAny to a specific URL?
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('user.urls')),
path('api/section/', include('section.urls')),
path('docs/', include_docs_urls(title='Great Soft Uz')) # I want this url to be public
]
Thanks in Advance
Upvotes: 4
Views: 2003
Reputation: 420
include_docs_urls function has a parameter with a default value like this permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES
def include_docs_urls(
title=None, description=None, schema_url=None, urlconf=None,
public=True, patterns=None, generator_class=SchemaGenerator,
authentication_classes=api_settings.DEFAULT_AUTHENTICATION_CLASSES,
permission_classes=api_settings.DEFAULT_PERMISSION_CLASSES,
renderer_classes=None):
# this is the declaration of the function
the default behavior is to extend the value of DEFAULT_PERMISSION_CLASSES from you settings but you can override it like this
from rest_framework.permissions import AllowAny
urlpatterns = [
path('docs/', include_docs_urls(title='Great Soft Uz', permission_classes=[AllowAny, ], authentication_classes=[]))
]
Upvotes: 5