Ticket #16704: 16704.csrftoken.diff

File 16704.csrftoken.diff, 952 bytes (added by Bas Peschier, 13 years ago)
  • docs/ref/contrib/csrf.txt

    diff -r 657f07fc5ef7 docs/ref/contrib/csrf.txt
    a b  
    146146:ttag:`csrf_token`, you may need to ensure the client receives the cookie by
    147147using :func:`~django.views.decorators.csrf.ensure_csrf_cookie`.
    148148
     149Other template engines
     150----------------------
     151
     152When using a different template engine than Django's built-in engine, you can
     153set the token in your forms manually after making sure it is available in the
     154context of the template.
     155
     156So in Cheetah for example, your form could contain the following:
     157
     158.. code-block:: html
     159
     160    <div style="display:none">
     161        <input type="hidden" name="csrfmiddlewaretoken" value="$csrf_token"/>
     162    </div>
     163
     164You may use javascript similar to the :ref:`AJAX code <csrf-ajax>` above to get
     165the value of the CSRF token.
     166
    149167The decorator method
    150168--------------------
    151169
Back to Top