Skip to content

Commit

Permalink
fixes response rendering with empty context (#4495)
Browse files Browse the repository at this point in the history
This commit allows `response.render` to be called when
`response.rendered_context == {}`. This should be allowed, since
if [the JSONRenderer, for example](https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/renderers.py#L85-L92) receives a `None` context, it
sets it to an empty dictionary itself.
  • Loading branch information
OJFord authored and tomchristie committed Sep 17, 2016
1 parent fe4c4fa commit fe96cec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rest_framework/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def rendered_content(self):

assert renderer, ".accepted_renderer not set on Response"
assert accepted_media_type, ".accepted_media_type not set on Response"
assert context, ".renderer_context not set on Response"
assert context is not None, ".renderer_context not set on Response"
context['response'] = self

media_type = renderer.media_type
Expand Down

0 comments on commit fe96cec

Please sign in to comment.