tags:

views:

62

answers:

1

I am trying to get if required "*" within lable tag. Somewhat close to this

<label for="id_name"><strong>Name</strong> <em>*</em></label>

With label_tag

{{ field.label_tag }}

it generates as

<label for="id_city">City</label>

this begins and closes label tag, how to insert "*" before closing

this hack seems to work,

<label for="id_{{ field.label }}">{{ field.label }} 
{% if field.field.required %}<em>*</em>{% endif %}</label> 

it is not functional as field label id would different than field label, as "name" not "Name"

+1  A: 

Your code is very similar to this Django snippet. A comment there suggests using:

    <label for="{{ field.auto_id }}">

instead of your:

    <label for="id_{{ field.label }}">

You can also try this snippet as an alternative.

Van Gale