-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
OrderingFilter
should call get_serializer_class()
to determine default fields.
#3964
Conversation
… view in OrderingFilter backend instead of calling the view's get_serializer_class method
@bmampaey Thanks! LGTM 👍 |
Need to figure out why the assertion is raised. |
@xordoquy My guess is during the check for |
Yep yep what @kevin-brown said |
ok, let me rephrase this. I'm a bit reluctant to leave the assertion error assume it'll only be the |
@xordoquy I see what you mean, but I don't think we're not even initializing a serializer in there, so I'm not sure from where else we could get thrown an assertion error at that point. |
if serializer_class is None: | ||
try: | ||
serializer_class = view.get_serializer_class() | ||
except AssertionError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to use except (AssertionError, AttributeError)
here, in case get_serializer_class
does not exist on the view (eg using basic APIView
, rather than the generic classes)
OrderingFilter
should call get_serializer_class()
to determine default fields.
Thanks folks - now all resolved. |
refs #3957
I made the proposed change
Because the default get_serializer_class method of GenericAPIView throw an Assertion error if there is no serializer_class defined on the view, I made a try except block that catches the exception and return the message as defined previously. I don't know if that is the correct idea.
I also added 3 tests for this fix.