Form.label_suffix
A translatable string (defaults to a colon (:
) in English) that will be appended after any label name when a form is rendered.
It’s possible to customize that character, or omit it entirely, using the label_suffix
parameter:
>>> f = ContactForm(auto_id='id_for_%s', label_suffix='') >>> print(f.as_ul()) <li><label for="id_for_subject">Subject</label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required /></li> <li><label for="id_for_message">Message</label> <input type="text" name="message" id="id_for_message" required /></li> <li><label for="id_for_sender">Sender</label> <input type="email" name="sender" id="id_for_sender" required /></li> <li><label for="id_for_cc_myself">Cc myself</label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself" /></li> >>> f = ContactForm(auto_id='id_for_%s', label_suffix=' ->') >>> print(f.as_ul()) <li><label for="id_for_subject">Subject -></label> <input id="id_for_subject" type="text" name="subject" maxlength="100" required /></li> <li><label for="id_for_message">Message -></label> <input type="text" name="message" id="id_for_message" required /></li> <li><label for="id_for_sender">Sender -></label> <input type="email" name="sender" id="id_for_sender" required /></li> <li><label for="id_for_cc_myself">Cc myself -></label> <input type="checkbox" name="cc_myself" id="id_for_cc_myself" /></li>
Note that the label suffix is added only if the last character of the label isn’t a punctuation character (in English, those are .
, !
, ?
or :
).
Fields can also define their own label_suffix
. This will take precedence over Form.label_suffix
. The suffix can also be overridden at runtime using the label_suffix
parameter to label_tag()
.
Please login to continue.