Skip to content

Commit

Permalink
Fix HiddenField stripping in BrowsableAPIRenderer (encode#5499)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby authored and Carlton Gibson committed Oct 16, 2017
1 parent c91b081 commit cbfa444
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rest_framework/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,12 @@ def get_raw_data_form(self, data, view, method, request):
accepted = self.accepted_media_type
context = self.renderer_context.copy()
context['indent'] = 4
data = {k: v for (k, v) in serializer.data.items()
if not isinstance(serializer.fields[k],
serializers.HiddenField)}

# strip HiddenField from output
data = serializer.data.copy()
for name, field in serializer.fields.items():
if isinstance(field, serializers.HiddenField):
data.pop(name, None)
content = renderer.render(data, accepted, context)
else:
content = None
Expand Down

0 comments on commit cbfa444

Please sign in to comment.