Reputation: 15620
Using Django 1.10. From the docs, it seems that I should be able to access help_text from the template but I can't.
class StudentForm(ModelForm):
class Meta:
model = Student
fields = ['name', 'age']
help_text = {
'age': "enter your age in years and months",
}
In the template, the following prints nothing:
{%for field in form %}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
{% endfor %}
Upvotes: 1
Views: 284
Reputation: 308829
Your template is OK. The problem is that the meta option should be help_texts
, not help_text
.
class Meta:
model = Student
fields = ['name', 'age']
help_texts = {
'age': "enter your age in years and months",
}
Upvotes: 3