[Fixed]-Django forms: add a custom label

1đź‘Ť

âś…

This is what the help_text attribute of a field is generally for. Think, for example, of a small caption that says “Two-letter abbreviation” below an input for a state/province.

...
{{ field }}
{% if field.help_text %}<div class='styleme'>{{ field.help_text }}</div>{% endif %}

Of course, you could always render each field individually if need be. Cleaner (if you have many fields) – test for when a certain field is in the loop.

{% if field.label == "A Certain Field" %}
    <div>Some text here</div>
{% endif %}
👤Ian Price

Leave a comment