Commit c2b9f649 authored by Julien Phalip's avatar Julien Phalip
Browse files

Added some sphinx cross-reference links to the built-in template tags and...

Added some sphinx cross-reference links to the built-in template tags and filters in multiple areas of the documentation. Also fixed a few minor inconsistencies and did a little PEP8 cleanup while I was at it.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16922 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent 0d9b6a5b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ passed around inside the template code:

      Internally, these strings are of type ``EscapeString`` or
      ``EscapeUnicode``. Generally you don't have to worry about these; they
      exist for the implementation of the ``escape`` filter.
      exist for the implementation of the :tfilter:`escape` filter.

Template filter code falls into one of two situations:

@@ -501,8 +501,8 @@ safe.

To make sure your template tags are thread safe, you should never store state
information on the node itself. For example, Django provides a builtin
``cycle`` template tag that cycles among a list of given strings each time it's
rendered:
:ttag:`cycle` template tag that cycles among a list of given strings each time
it's rendered:

.. code-block:: html+django

+5 −4
Original line number Diff line number Diff line
@@ -223,7 +223,8 @@ This is probably the most common case, if you're using Django's admin site:
.. _mod_rewrite: http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Django will automatically use the pre-rewrite version of the URL when
constructing URLs with the ``{% url %}`` template tag (and similar methods).
constructing URLs with the :ttag:`{% url %}<url>` template tag (and similar
methods).

Using mod_fcgid as alternative to mod_fastcgi
----------------------------------------------
@@ -409,8 +410,8 @@ Because many of these fastcgi-based solutions require rewriting the URL at
some point inside the Web server, the path information that Django sees may not
resemble the original URL that was passed in. This is a problem if the Django
application is being served from under a particular prefix and you want your
URLs from the ``{% url %}`` tag to look like the prefix, rather than the
rewritten version, which might contain, for example, ``mysite.fcgi``.
URLs from the :ttag:`{% url %}<url>` tag to look like the prefix, rather than
the rewritten version, which might contain, for example, ``mysite.fcgi``.

Django makes a good attempt to work out what the real script name prefix
should be. In particular, if the Web server sets the ``SCRIPT_URL`` (specific
+4 −3
Original line number Diff line number Diff line
@@ -420,9 +420,10 @@ on the object ``poll``. Failing that, it tries an attribute lookup -- which
works, in this case. If attribute lookup had failed, it would've tried a
list-index lookup.

Method-calling happens in the ``{% for %}`` loop: ``poll.choice_set.all`` is
interpreted as the Python code ``poll.choice_set.all()``, which returns an
iterable of Choice objects and is suitable for use in the ``{% for %}`` tag.
Method-calling happens in the :ttag:`{% for %}<for>` loop:
``poll.choice_set.all`` is interpreted as the Python code
``poll.choice_set.all()``, which returns an iterable of Choice objects and is
suitable for use in the :ttag:`{% for %}<for>` tag.

See the :doc:`template guide </topics/templates>` for more about templates.

+6 −6
Original line number Diff line number Diff line
@@ -49,13 +49,13 @@ A quick rundown:
      data), we need to worry about Cross Site Request Forgeries.
      Thankfully, you don't have to worry too hard, because Django comes with
      a very easy-to-use system for protecting against it. In short, all POST
      forms that are targeted at internal URLs should use the ``{% csrf_token %}``
      template tag.
      forms that are targeted at internal URLs should use the
      :ttag:`{% csrf_token %}<csrf_token>` template tag.

The ``{% csrf_token %}`` tag requires information from the request object, which
is not normally accessible from within the template context. To fix this, a
small adjustment needs to be made to the ``detail`` view, so that it looks like
the following::
The :ttag:`{% csrf_token %}<csrf_token>` tag requires information from the
request object, which is not normally accessible from within the template
context. To fix this, a small adjustment needs to be made to the ``detail``
view, so that it looks like the following::

    from django.template import RequestContext
    # ...
+3 −3
Original line number Diff line number Diff line
@@ -1963,7 +1963,7 @@ For more details, see the documentation on :ref:`reversing namespaced URLs
<topics-http-reversing-url-namespaces>`.

To allow easier reversing of the admin urls in templates, Django provides an
``admin_url`` filter which takes an action as argument:
``admin_urlname`` filter which takes an action as argument:

.. code-block:: html+django

Loading