Error: The response content must be rendered before it can be accessed.

4,027 views
Skip to first unread message

sonu kumar

unread,
Nov 4, 2015, 3:51:53 PM11/4/15
to Django users
class based views are as below
class TagList(TemplateView):
     def get_context_data(self, **kwargs):
         ...
         qlist = QueList.as_view()(self.request, **kwargs)
print qlist
         ...

class QueListView(ListView):
def get_context_data(self, **kwargs):
        ...

When QuesList.as_view() is called then it produces The response content must be rendered before it can be accessed . on print qlist line How to fix this error and what's reason behind this?

Daniel Roseman

unread,
Nov 4, 2015, 4:14:22 PM11/4/15
to Django users
Because a TemplateView returns a TemplateResponse, which needs to be rendered. See the docs: https://docs.djangoproject.com/en/1.8/ref/template-response/

Can you explain why you are doing this? What's the point of calling one view from another? There's almost certainly a better way to achieve what you want. 
--
DR.

sonu kumar

unread,
Nov 4, 2015, 10:34:25 PM11/4/15
to Django users
I am having different URLs configuration. same view is called for two URLs based on **kwargs decision is made what to do? In one of case I need to get result of all related objects which is tagged with given keyword. I found another way to do achieve same using function based view.
Reply all
Reply to author
Forward
0 new messages