-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeated warnings view has no attribute 'get_serializer' #28
Comments
warning are emitted for every operation (method+endpoint). no easy way around it. once the schema approaches a good state there should be rarely any warning. i think i understand the problem with i'll check if serializer retrieval can be a bit more forgiving. |
@jayvdb please try again. i added some educated guesses, which should at least solve some of the things django-oscar-api is doing. |
Another 89 warnings removed, down to 810. WARNING #511: Exception raised while getting serializer from CheckoutView. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: `PaymentMethodsSerializer` requires the request in the serializer context. Add `context={'request': request}` when instantiating the serializer.)
WARNING #512: Exception raised while getting serializer from CheckoutView. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: `PaymentMethodsSerializer` requires the request in the serializer context. Add `context={'request': request}` when instantiating the serializer.)
WARNING #513: Exception raised while getting serializer from CheckoutView. Hint: Is get_serializer_class() returning None or is get_queryset() not working without a request? Ignoring the view for now. (Exception: `PaymentMethodsSerializer` requires the request in the serializer context. Add `context={'request': request}` when instantiating the serializer.)
...
WARNING #769: Unable to guess serializer for LogoutView. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. ignoring view for now.
WARNING #770: Unable to guess serializer for LogoutView. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. ignoring view for now.
WARNING #771: Unable to guess serializer for LogoutView. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. ignoring view for now.
...
WARNING #803: Unable to guess serializer for wrapped_target. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. ignoring view for now.
WARNING #804: Unable to guess serializer for wrapped_target. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. ignoring view for now.
WARNING #805: Unable to guess serializer for wrapped_target. This is graceful fallback handling for APIViews. Consider using GenericAPIView as view base class, if view is under your control. ignoring view for now. It should be possible to have a mapping/cache that allows only one warning per view, but you are in a better position to understand why that might not be possible. |
If I dont use silk-profile, I get three warnings for url entry
@api_view(['POST'])
@permission_classes((TokenHasReadWriteScope, ))
def get_user_jwt(request, *args, **kwargs):
"""
This converts the access token by
django-rest-framework-social-oauth2 to JWT.
The request header should contain the token as:
`Authentication: Bearer <access_token>`
"""
user = request.user
serializer = UserSerializer(user)
return JsonResponse({'user': serializer.data,
'token': generate_jwt_token(serializer.data)},
status=200) |
https://github.com/RealmTeam/django-rest-framework-social-oauth2/blob/f9de220606bd08981b9d81ab80dd69d70ceb1988/rest_framework_social_oauth2/views.py (current master) uses both |
rest framework generates |
Some stats on the repeated nature of these warnings that I am seeing:
|
Here are the only remaining warnings which mention 'exception'. All of these are django-oscar-api
The warning mentions "is get_queryset() not working without a request?" , and that is clear for at least two of them, and my guess is it also applies to the third. |
i consider the duplicate warnings very low prio atm. good application for i'm evaluating whether i should introduce a "mocked" request to allow for simple processing. i did something similar for OAuth2 permission parsing. depending on what those serializers do with the request, that may solve it or not. generally, there is a limit on how much opaque "magic" the introspection can overcome. |
no. setting the auth/permission on the schema operation has nothing to do with the parsing of the actual library endpoints for authentication.
same issue. @api_view -> WrappedAPIView -> APIView which again does not hold any information on the model. no model = no way to pull the type of maybe we need a way to override autodiscovery with manually given info. since lib code is not under your control, you cannot add |
@jayvdb i took your advice to heart. duplicate warnings are not that nice. closing this issue as the main issue is resolved. |
This is while processing django-oscar-api. Ideally the lack of a get_serializer is noticed once per view and only one warning is emitted.
The text was updated successfully, but these errors were encountered: