Fixed #15241 -- Updated the upgrading notes for generic views to reflect recent changes in class-based views. Thanks to Jonney for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15479 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0d9c5d5a5e
commit
8c59905033
|
@ -128,12 +128,12 @@ as way to control the mimetype of the response.
|
||||||
|
|
||||||
Class-based views don't provide a ``mimetype`` argument. Instead, you
|
Class-based views don't provide a ``mimetype`` argument. Instead, you
|
||||||
subclass the view, overriding
|
subclass the view, overriding
|
||||||
:meth:`TemplateResponseMixin.get_response()` and pass in arguments for
|
:meth:`TemplateResponseMixin.render_to_response()` and pass in arguments for
|
||||||
the HttpResponse constructor. For example::
|
the TemplateResponse constructor. For example::
|
||||||
|
|
||||||
class MyListView(ListView):
|
class MyListView(ListView):
|
||||||
def get_response(self, content, **kwargs):
|
def render_to_response(self, context, **kwargs):
|
||||||
return super(MyListView, self).get_response(content,
|
return super(MyListView, self).render_to_response(context,
|
||||||
content_type='application/json', **kwargs)
|
content_type='application/json', **kwargs)
|
||||||
|
|
||||||
``context_processors``
|
``context_processors``
|
||||||
|
@ -145,10 +145,9 @@ processors when rendering template content.
|
||||||
|
|
||||||
Class-based views don't provide a ``context_processors`` argument.
|
Class-based views don't provide a ``context_processors`` argument.
|
||||||
Instead, you subclass the view, overriding
|
Instead, you subclass the view, overriding
|
||||||
:meth:`TemplateResponseMixin.get_context_instance()`. For example::
|
:meth:`TemplateResponseMixin.render_to_response()`. For example::
|
||||||
|
|
||||||
class MyListView(ListView):
|
class MyListView(ListView):
|
||||||
def get_context_instance(self, context):
|
def render_to_response(self, context, **kwargs):
|
||||||
return RequestContext(self.request,
|
return super(MyListView, self).render_to_response(
|
||||||
context,
|
RequestContext(self.request, context, processors=[custom_processor]), **kwargs)
|
||||||
processors=[custom_processor])
|
|
||||||
|
|
Loading…
Reference in New Issue