Ticket #15241: generic-views-migration.patch

File generic-views-migration.patch, 1.7 KB (added by Jonney, 14 years ago)
  • docs/topics/generic-views-migration.txt

     
    128128
    129129Class-based views don't provide a ``mimetype`` argument. Instead, you
    130130subclass the view, overriding
    131 :meth:`TemplateResponseMixin.get_response()` and pass in arguments for
    132 the HttpResponse constructor. For example::
     131:meth:`TemplateResponseMixin.render_to_response()` and pass in arguments for
     132the TemplateResponse constructor. For example::
    133133
    134134    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,
    137137                            content_type='text/plain', **kwargs)
    138138
    139139``context_processors``
     
    145145
    146146Class-based views don't provide a ``context_processors`` argument.
    147147Instead, you subclass the view, overriding
    148 :meth:`TemplateResponseMixin.get_context_instance()`. For example::
     148:meth:`TemplateResponseMixin.render_to_response()`. For example::
    149149
    150150    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)
Back to Top