django-uni-form helpers and CSRF tags over POST
Posted
by
linked
on Stack Overflow
See other posts from Stack Overflow
or by linked
Published on 2011-01-22T22:55:34Z
Indexed on
2011/02/03
7:25 UTC
Read the original article
Hit count: 274
Hi, I'm using django-uni-forms to display my fields, with a rather rudimentary example straight out of their book.
When I render the form fields using <form>{%csrf_tag%} {%form|as_uni_form%}</form>
, everything works as expected.
However, django-uni-form Helpers allow you to generate the form tag (and other helper-related content) using the following syntax -- {% with form.helper as helper %}{% uni_form form helper%}{%endwith%}
-- This creates the <form>
tag for me, so there's nowhere to embed my own CSRF_token. When I try to use this syntax, the form renders perfectly, but without a CSRF token, and so submitting the form fails every time.
Does anyone have experience with this? Is there an established way to add the token? I much prefer the second syntax, for re-use reasons. Thanks!
© Stack Overflow or respective owner