From fe96ceced08fa36db122deeb53e525e25e3f3daf Mon Sep 17 00:00:00 2001 From: Ollie Ford Date: Sat, 17 Sep 2016 03:13:34 +0100 Subject: [PATCH] fixes response rendering with empty context (#4495) 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. --- rest_framework/response.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/response.py b/rest_framework/response.py index 4b863cb99..cb0f290ce 100644 --- a/rest_framework/response.py +++ b/rest_framework/response.py @@ -56,7 +56,7 @@ class Response(SimpleTemplateResponse): 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