Newline in label for Django form field
You can use mark_safe
so that the <br />
tag is not escaped.
It's equivalent to using safe
in the template, so be careful if you're handling user input. If it's a hardcoded string, then it's safe to use.
from django import formsfrom django.utils.safestring import mark_safeclass MyForm(forms.Form): my_field = forms.CharField(label=mark_safe('my label<br />next line'))