Ticket #15241: generic-views-migration.patch
File generic-views-migration.patch, 1.7 KB (added by , 14 years ago) |
---|
-
docs/topics/generic-views-migration.txt
128 128 129 129 Class-based views don't provide a ``mimetype`` argument. Instead, you 130 130 subclass the view, overriding 131 :meth:`TemplateResponseMixin. get_response()` and pass in arguments for132 the HttpResponse constructor. For example::131 :meth:`TemplateResponseMixin.render_to_response()` and pass in arguments for 132 the TemplateResponse constructor. For example:: 133 133 134 134 class MyListView(ListView): 135 def get_response(self, content, **kwargs):136 return super(MyListView, self). get_response(content,135 def render_to_response(self, context, **kwargs): 136 return super(MyListView, self).render_to_response(context, 137 137 content_type='text/plain', **kwargs) 138 138 139 139 ``context_processors`` … … 145 145 146 146 Class-based views don't provide a ``context_processors`` argument. 147 147 Instead, you subclass the view, overriding 148 :meth:`TemplateResponseMixin. get_context_instance()`. For example::148 :meth:`TemplateResponseMixin.render_to_response()`. For example:: 149 149 150 150 class MyListView(ListView): 151 def get_context_instance(self, context): 152 return RequestContext(self.request, 153 context, 154 processors=[custom_processor]) 151 def render_to_response(self, context, **kwargs): 152 return super(MyListView, self).render_to_response( 153 RequestContext(self.request, context, processors=[custom_processor]), **kwargs)