Commit 4d83b016 authored by Tim Graham's avatar Tim Graham
Browse files

Fixed #25969 -- Replaced render_to_response() with render() in docs examples.

parent edf3b88f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
  Example:

   * In the view:
      return render_to_response('template.html', {'google' : GoogleMap(key="abcdefg")})
      return render(request, 'template.html', {'google': GoogleMap(key="abcdefg")})

   * In the template:

+8 −6
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ class GEvent(object):

    Example:

      from django.shortcuts import render_to_response
      from django.shortcuts import render
      from django.contrib.gis.maps.google import GoogleMap, GEvent, GPolyline

      def sample_request(request):
@@ -32,8 +32,9 @@ class GEvent(object):
          event = GEvent('click',
            'function() { location.href = "http://www.google.com"}')
          polyline.add_event(event)
          return render_to_response('mytemplate.html',
          {'google' : GoogleMap(polylines=[polyline])})
          return render(request, 'mytemplate.html', {
              'google': GoogleMap(polylines=[polyline]),
          })
    """

    def __init__(self, event, action):
@@ -271,7 +272,7 @@ class GMarker(GOverlayBase):

    Example:

      from django.shortcuts import render_to_response
      from django.shortcuts import render
      from django.contrib.gis.maps.google.overlays import GMarker, GEvent

      def sample_request(request):
@@ -279,8 +280,9 @@ class GMarker(GOverlayBase):
          event = GEvent('click',
                         'function() { location.href = "http://www.google.com"}')
          marker.add_event(event)
          return render_to_response('mytemplate.html',
                 {'google' : GoogleMap(markers=[marker])})
          return render(request, 'mytemplate.html', {
              'google': GoogleMap(markers=[marker]),
          })
    """
    def __init__(self, geom, title=None, draggable=False, icon=None):
        """
+2 −2
Original line number Diff line number Diff line
@@ -553,8 +553,8 @@ details on these changes.
  :class:`~django.template.response.SimpleTemplateResponse`, and
  :class:`~django.template.response.TemplateResponse`, will be removed.
  ``content_type`` should be used instead. This also applies to the
  :func:`~django.shortcuts.render_to_response` shortcut and
  the sitemap views, :func:`~django.contrib.sitemaps.views.index` and
  ``render_to_response()`` shortcut and the sitemap views,
  :func:`~django.contrib.sitemaps.views.index` and
  :func:`~django.contrib.sitemaps.views.sitemap`.

* When :class:`~django.http.HttpResponse` is instantiated with an iterator,
+5 −25
Original line number Diff line number Diff line
@@ -45,31 +45,11 @@ To take advantage of CSRF protection in your views, follow these steps:
   This should not be done for POST forms that target external URLs, since
   that would cause the CSRF token to be leaked, leading to a vulnerability.

3. In the corresponding view functions, ensure that the
   ``'django.template.context_processors.csrf'`` context processor is
   being used. Usually, this can be done in one of two ways:

   1. Use RequestContext, which always uses
      ``'django.template.context_processors.csrf'`` (no matter what template
      context processors are configured in the :setting:`TEMPLATES` setting).
      If you are using generic views or contrib apps, you are covered already,
      since these apps use RequestContext throughout.

   2. Manually import and use the processor to generate the CSRF token and
      add it to the template context. e.g.::

          from django.shortcuts import render_to_response
          from django.template.context_processors import csrf

          def my_view(request):
              c = {}
              c.update(csrf(request))
              # ... view code here
              return render_to_response("a_template.html", c)

      You may want to write your own
      :func:`~django.shortcuts.render_to_response()` wrapper that takes care
      of this step for you.
3. In the corresponding view functions, ensure that
   :class:`~django.template.RequestContext` is used to render the response so
   that ``{% csrf_token %}`` will work properly. If you're using the
   :func:`~django.shortcuts.render` function, generic views, or contrib apps,
   you are covered already since these all use ``RequestContext``.

.. _csrf-ajax:

+1 −2
Original line number Diff line number Diff line
@@ -283,8 +283,7 @@ Using TemplateResponse and SimpleTemplateResponse

A :class:`TemplateResponse` object can be used anywhere that a normal
:class:`django.http.HttpResponse` can be used. It can also be used as an
alternative to calling :func:`~django.shortcuts.render()` or
:func:`~django.shortcuts.render_to_response()`.
alternative to calling :func:`~django.shortcuts.render()`.

For example, the following simple view returns a :class:`TemplateResponse`
with a simple template and a context containing a queryset::
Loading