Tweaked some `render_to_response` links in the documentation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16255 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
a8598c7de2
commit
50ad59527c
|
@ -66,8 +66,9 @@ To enable CSRF protection for your views, follow these steps:
|
||||||
# ... view code here
|
# ... view code here
|
||||||
return render_to_response("a_template.html", c)
|
return render_to_response("a_template.html", c)
|
||||||
|
|
||||||
You may want to write your own ``render_to_response`` wrapper that
|
You may want to write your own
|
||||||
takes care of this step for you.
|
:func:`~django.shortcuts.render_to_response()` wrapper that takes care
|
||||||
|
of this step for you.
|
||||||
|
|
||||||
The utility script ``extras/csrf_migration_helper.py`` can help to automate the
|
The utility script ``extras/csrf_migration_helper.py`` can help to automate the
|
||||||
finding of code and templates that may need these steps. It contains full help
|
finding of code and templates that may need these steps. It contains full help
|
||||||
|
|
|
@ -273,7 +273,7 @@ Using TemplateResponse and SimpleTemplateResponse
|
||||||
|
|
||||||
A TemplateResponse object can be used anywhere that a normal
|
A TemplateResponse object can be used anywhere that a normal
|
||||||
HttpResponse can be used. It can also be used as an alternative to
|
HttpResponse can be used. It can also be used as an alternative to
|
||||||
calling :meth:`~django.shortcuts.render_to_response()`.
|
calling :func:`~django.shortcuts.render_to_response()`.
|
||||||
|
|
||||||
For example, the following simple view returns a
|
For example, the following simple view returns a
|
||||||
:class:`TemplateResponse()` with a simple template, and a context
|
:class:`TemplateResponse()` with a simple template, and a context
|
||||||
|
|
|
@ -404,11 +404,12 @@ optional, third positional argument, ``processors``. In this example, the
|
||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
If you're using Django's ``render_to_response()`` shortcut to populate a
|
If you're using Django's :func:`~django.shortcuts.render_to_response()`
|
||||||
template with the contents of a dictionary, your template will be passed a
|
shortcut to populate a template with the contents of a dictionary, your
|
||||||
``Context`` instance by default (not a ``RequestContext``). To use a
|
template will be passed a ``Context`` instance by default (not a
|
||||||
``RequestContext`` in your template rendering, pass an optional third
|
``RequestContext``). To use a ``RequestContext`` in your template rendering,
|
||||||
argument to ``render_to_response()``: a ``RequestContext``
|
pass an optional third argument to
|
||||||
|
:func:`~django.shortcuts.render_to_response()`: a ``RequestContext``
|
||||||
instance. Your code might look like this::
|
instance. Your code might look like this::
|
||||||
|
|
||||||
def some_view(request):
|
def some_view(request):
|
||||||
|
@ -789,7 +790,7 @@ implement this API we can use third party template systems like `Jinja2
|
||||||
<http://jinja.pocoo.org/2/>`_ or `Cheetah <http://www.cheetahtemplate.org/>`_. This
|
<http://jinja.pocoo.org/2/>`_ or `Cheetah <http://www.cheetahtemplate.org/>`_. This
|
||||||
allows us to use third-party template libraries without giving up useful Django
|
allows us to use third-party template libraries without giving up useful Django
|
||||||
features like the Django ``Context`` object and handy shortcuts like
|
features like the Django ``Context`` object and handy shortcuts like
|
||||||
``render_to_response()``.
|
:func:`~django.shortcuts.render_to_response()`.
|
||||||
|
|
||||||
The core component of the Django templating system is the ``Template`` class.
|
The core component of the Django templating system is the ``Template`` class.
|
||||||
This class has a very simple interface: it has a constructor that takes a single
|
This class has a very simple interface: it has a constructor that takes a single
|
||||||
|
|
|
@ -550,8 +550,8 @@ requested::
|
||||||
return SingleObjectTemplateResponseMixin.render_to_response(self, context)
|
return SingleObjectTemplateResponseMixin.render_to_response(self, context)
|
||||||
|
|
||||||
Because of the way that Python resolves method overloading, the local
|
Because of the way that Python resolves method overloading, the local
|
||||||
:func:`render_to_response()` implementation will override the
|
``render_to_response()`` implementation will override the versions provided by
|
||||||
versions provided by :class:`JSONResponseMixin` and
|
:class:`JSONResponseMixin` and
|
||||||
:class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.
|
:class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.
|
||||||
|
|
||||||
Decorating class-based views
|
Decorating class-based views
|
||||||
|
@ -613,4 +613,4 @@ login protection.
|
||||||
``method_decorator`` passes ``*args`` and ``**kwargs``
|
``method_decorator`` passes ``*args`` and ``**kwargs``
|
||||||
as parameters to the decorated method on the class. If your method
|
as parameters to the decorated method on the class. If your method
|
||||||
does not accept a compatible set of parameters it will raise a
|
does not accept a compatible set of parameters it will raise a
|
||||||
``TypeError`` exception.
|
``TypeError`` exception.
|
||||||
|
|
Loading…
Reference in New Issue