13👍
✅
Turned out the issue was that I was missing rest_framework.authentication.SessionAuthentication
in DRF’s DEFAULT_AUTHENTICATION_CLASSES
.
So the request object sent after logging in via the Django Admin login view did not have a user so all permission classes kept failing and it would then lead to the above error.
So after adding it drf-yasg shows all its glory.
Bug:
The error it throws when this occurs was raised as bug though. See #issue58.
0👍
you should set the authentication class in schema view if you only use JWT:
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework_simplejwt.authentication.JWTAuthentication",
],
}
so your schema view should be something like that:
schema_view = get_schema_view(
openapi.Info(
title="Swagger Doc",
default_version='v1',
description="Test description",
terms_of_service="https://www.google.com/policies/terms/",
contact=openapi.Contact(email="contact@snippets.local"),
license=openapi.License(name="BSD License"),
),
authentication_classes=(authentication.BasicAuthentication,),
public=True,
)
it should work and ask you to set your username and password.
- How to limit queryset/the records to view in Django admin site?
- "Error: That IP address can't be assigned-to" when running app
- Reusable HTML component libraries in Django
- How to pass arguments with slash in Django2 urls
- Modulo in django queryset?
Source:stackexchange.com