views:

147

answers:

2

I'm rendering a form. I would like to put a mark next to all the fields that must be filled in. Simple stuff usually... but I've no idea how to access that information!

{% if field.required %}REQUIRED!!{% endif %}

doesn't bring any love...

+3  A: 
{% if field.field.required %}

From this snippet

Ned Batchelder
Urgh... Of course! Thank you!
Oli
A: 

I usually write out the html for each of my form elements, so I have a little more control over each one. Then you can add an * for required or REQUIRED!!.

<p><label>Title: *<br />
{% if form.title.errors %}<ul class="errorlist">{{ form.title.errors }}</ul>{% endif %}
{{form.title}}
</label></p>    

<p><label>Category:<br />
{% if form.category.errors %}<ul class="errorlist">{{ form.category.errors }}</ul>{% endif %}
{{form.category}}
</label></p>
Joe
Would be cool to see this as a custom template tag.
dfrankow