I am using the django.contrib.auth registration form and trying to get the help text to display consistently for all fields using Bootstrap.
I am using the following code in my Django template for the help text as part of a for loop on the form:
<p class="help-block">{{ field.help_text }}</p>
This works fine apart from the help text for the password field where it displays with the html tags:
To prevent this I changed the code above to:
<p class="help-block">{{ field.help_text|safe }}</p>
But now the help text is not being formatted by Bootstrap, I guess because of the html inside the paragraph block.
help-block no longer formatting
Is there an obvious step I'm missing or is there another way this can be done?
Thanks.
Okay, late answer, but you can override the help text in the form, and make it whatever you want.
For example:
class MyRegistrationForm(RegistrationForm):
def __init__(self, *args, **kwargs):
super(MyRegistrationForm, self).__init__(*args, **kwargs)
self.fields['password'].help_text = 'Password help text with whatever tags you want.'