troubles at rendering the form field label in Django

When I tried to render field label, that contains HTML tags, in the template, it was rendered to the simple text.

erotrotsity = forms.DecimalField(max_digits=7, decimal_places=3, label='Erot<sup>12</sup>', required=False, validators = [MinValueValidator(0)])

filter |safe and autoescape don't work

Upvotes: 0

Views: 62

Answers (1)

Alasdair
Alasdair

Reputation: 308859

Use mark_safe():

from django.utils.safestring import mark_safe

erotrotsity = forms.DecimalField(max_digits=7, decimal_places=3, label=mark_safe('Erot<sup>12</sup>'), required=False, validators = [MinValueValidator(0)])

Upvotes: 1

Related Questions