Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updated NestedBoundField to also handle empty string when rendering its form#3677

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lovelydinosaur merged 2 commits intoencode:masterfromErnest0x:patch-4
Nov 27, 2015

Conversation

@Ernest0x
Copy link
Contributor

If a NestedBoundField field has a value ofNone and is inside another NestedBoundField field, it will have its value converted to an empty string while the form of its enclosing field is being rendered. So, NestedBoundField fields with an empty string value must be handled the same way as NestedBoundField fields with aNone value.

…ts formIf a NestedBoundField field has a value of `None` and is inside another NestedBoundField field, it will have its value converted to an empty string while the form of its enclosing field is being rendered. So, NestedBoundField fields with an empty string value must be handled the same way as NestedBoundField fields with a `None` value.
@lovelydinosaur
Copy link
Contributor

Could you give a simple example, demonstrating exactly what gets rendered incorrectly, and how this fix affects it?

@Ernest0x
Copy link
ContributorAuthor

Could you give a simple example, demonstrating exactly what gets rendered incorrectly, and how this fix affects it?

Of course. I have made the following#3464 (comment)

@lovelydinosaur
Copy link
Contributor

Okay. That's something, tho a minimal code example would still be helpful.

@andrewdodd
Copy link

I agree, I'd love to see a basic example of how this occurs.

@Ernest0x
Copy link
ContributorAuthor

Ok, here is code that reproduces exactly the error that this pull request fixes:

fromrest_frameworkimportserializersfromrest_framework.renderersimportHTMLFormRendererclassLevel2NestedSerializer(serializers.Serializer):some_field=serializers.CharField()classLevel1NestedSerializer(serializers.Serializer):nested2_field=Level2NestedSerializer(allow_null=True)another_field=serializers.CharField()classLevel0NestedSerializer(serializers.Serializer):nested1_field=Level1NestedSerializer()serializer=Level0NestedSerializer(data={'nested1_field': {'nested2_field':None,'another_field':'test'    }})serializer.is_valid()renderer=HTMLFormRenderer()forfieldinserializer:rendered=renderer.render_field(field, {})

@lovelydinosaur
Copy link
Contributor

Okay, and how does the HTML form render before/after the fix. (Include screenshots if you're feeling generous! 😎 )

@Ernest0x
Copy link
ContributorAuthor

Okay, and how does the HTML form render before/after the fix. (Include screenshots if you're feeling generous! )

Before the fix, it does not render at all. It crashes with a traceback.
After the fix, it renders ok. For the nested field withNone value, an empty form is rendered.

@lovelydinosaur
Copy link
Contributor

Would you consider pulling together a test case? Failing that wemight consider merging in any case and adding that as an outstanding issue.

@Ernest0x
Copy link
ContributorAuthor

Would you consider pulling together a test case?

Sure. Added in this pull request.

lovelydinosaur added a commit that referenced this pull requestNov 27, 2015
Updated NestedBoundField to also handle empty string when rendering its form
@lovelydinosaurlovelydinosaur merged commit8dea1ae intoencode:masterNov 27, 2015
@lovelydinosaur
Copy link
Contributor

Good stuff, thanks!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

3.3.2 Release

Development

Successfully merging this pull request may close these issues.

3 participants

@Ernest0x@lovelydinosaur@andrewdodd

[8]ページ先頭

©2009-2025 Movatter.jp