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

FixesBrowsableAPIRenderer for usage withListSerializer.#7530

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

Conversation

@NiyazNz
Copy link
Contributor

@NiyazNzNiyazNz commentedSep 10, 2020
edited
Loading

When using ListSerializer as viewset serializer_class rendering of view in BrowsableAPI fails with:

Internal Server Error: /api/snippets/Traceback (most recent call last):  File "/home/nz/.local/lib/virtualenvs/django-rest-framework-demo/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner    response = get_response(request)               ^^^^^^^^^^^^^^^^^^^^^  File "/home/nz/.local/lib/virtualenvs/django-rest-framework-demo/lib/python3.11/site-packages/django/core/handlers/base.py", line 220, in _get_response    response = response.render()               ^^^^^^^^^^^^^^^^^  File "/home/nz/.local/lib/virtualenvs/django-rest-framework-demo/lib/python3.11/site-packages/django/template/response.py", line 114, in render    self.content = self.rendered_content                   ^^^^^^^^^^^^^^^^^^^^^  File "/home/nz/dev/.oss/django-rest-framework/rest_framework/response.py", line 74, in rendered_content    ret = renderer.render(self.data, accepted_media_type, context)          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/nz/dev/.oss/django-rest-framework/rest_framework/renderers.py", line 725, in render    context = self.get_context(data, accepted_media_type, renderer_context)              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/nz/dev/.oss/django-rest-framework/rest_framework/renderers.py", line 656, in get_context    raw_data_post_form = self.get_raw_data_form(data, view, 'POST', request)                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "/home/nz/dev/.oss/django-rest-framework/rest_framework/renderers.py", line 564, in get_raw_data_form    for name, field in serializer.fields.items():                       ^^^^^^^^^^^^^^^^^AttributeError: 'MultipleSnippetSerializer' object has no attribute 'fields'[12/Jun/2023 08:41:53] "GET /api/snippets/ HTTP/1.1" 500 97475

BrowsableAPIRenderer cannot render multiple objects in HTML form and should render list example in Raw data.

This PR fixes the issue described above by rendering list of items in Raw data tab and not rendering HTML data tab while ListSerializer is used for viewset serializer_class.
image

@stale
Copy link

stalebot commentedMay 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelMay 1, 2022
@NiyazNzNiyazNzforce-pushed thefix-browsable-api-list-serializer-rendering branch from33df4bb toff1778eCompareMay 3, 2022 15:26
@stalestalebot removed the stale labelMay 3, 2022
@stale
Copy link

stalebot commentedJul 10, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelJul 10, 2022
@stalestalebot closed thisDec 24, 2022
@auvipyauvipy reopened thisDec 24, 2022
@stalestalebot removed the stale labelDec 24, 2022
@stale
Copy link

stalebot commentedApr 2, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelApr 2, 2023
@auvipyauvipy removed the stale labelApr 3, 2023
@stale
Copy link

stalebot commentedJun 10, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stalestalebot added the stale labelJun 10, 2023
Copy link
Collaborator

@auvipyauvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

can you please rebase to fix the failing CI?

@stalestalebot removed the stale labelJun 10, 2023
Renders list of items in raw_data_form and does not renders form intemplate while using with `ListSerializer` (`many=True`).
@NiyazNzNiyazNzforce-pushed thefix-browsable-api-list-serializer-rendering branch fromff1778e to837360eCompareJune 12, 2023 08:45
@NiyazNzNiyazNz requested a review fromauvipyJune 12, 2023 09:16
@auvipyauvipy added this to the3.15 milestoneJun 12, 2023
@auvipyauvipy merged commit02d9bfc intoencode:masterJun 12, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@auvipyauvipyauvipy approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

3.15

Development

Successfully merging this pull request may close these issues.

2 participants

@NiyazNz@auvipy

[8]ページ先頭

©2009-2025 Movatter.jp