Skip to content

Conversation

tbrknt
Copy link
Contributor

@tbrknt tbrknt commented Feb 22, 2021

Handle non-dict values for NestedSerializer during BrowsableAPI rendering.

Description

This PR is created in order to fix issue #7706. When a value that is not a Mappable is provided to a nested serializer, the rendering of NestedBoundField, which takes place for Browsable API, ends up in an error, which is not caught. Here, the suggested solution is to an empty dict if it is not an instance of any Mappable such as dict. Since the data is not valid and the validation error is not a field-specific error, I did not try to find a solution to show it in the HTML form in browsable API. Instead, I decided not to show that error in the HTML form and to convert the data to an empty dict since it cannot be properly shown on the HTML form.

fix #7706
refs #7706

Handle non-dict values for NestedSerializer during BrowsableAPI
rendering.
@tbrknt tbrknt marked this pull request as ready for review February 22, 2021 14:06
@lovelydinosaur lovelydinosaur mentioned this pull request Mar 9, 2021
@lovelydinosaur
Copy link
Contributor

Seems okay, yup. Thanks!

@lovelydinosaur lovelydinosaur merged commit 95ae92e into encode:master Mar 9, 2021
stefanacin pushed a commit to stefanacin/django-rest-framework that referenced this pull request Mar 22, 2021
Handle non-dict values for NestedSerializer during BrowsableAPI
rendering.
@tbrknt tbrknt deleted the fix-non-dict-nested-7706 branch May 25, 2021 07:22
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
Handle non-dict values for NestedSerializer during BrowsableAPI
rendering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rendering of Nested Serializer fails if no dictionary is parsed

2 participants