Within my model I have defined a required field class like this:
class Contact(models.Model):
last_name = models.CharField(_(u"Last Name"), max_length=50)
For the form I am simply using the ModelForm to keep it simple:
class ContactsForm(ModelForm):
class Meta:
model = Contact
I understand there are third-party-mods helping with rendering forms, however going plain for now to see when I hit the limitations, so I tried this:
<tr>
<td>
{{form.last_name.label}}:
</td>
<td>
{{form.last_name}}
{% if form.last_name.required %}(*){% endif %}
</td>
</tr>
Surprisingly I don’t get to see the (*) even though its a required field.
What am I missing?
I can’t test this now, but I’m pretty sure you need
form.last_name.field.required–form.last_nameis an instance ofBoundField, and it has afieldproperty which points to the originalCharField, which in turn contains therequiredproperty.