other_quantity = forms.IntegerField(
required=False,
widget=forms.TextInput(
attrs={"class": "form-control", "placeholder": "in meter cube(m3)"}
),
label="<b>#</b> Quantity of Other Material to be Remove ",
)
我想在我的占位符中使用立方米符号。尝试使用sup
标签,但它不起作用。
将上标三个 HTML 实体与 Django 的mark_safe
结合使用。
from django.utils.safestring import mark_safe
mark_safe("in m³")
在您的情况下,这将是
from django.utils.safestring import mark_safe
...
other_quantity = forms.IntegerField(
required=False,
widget=forms.TextInput(
attrs={"class": "form-control", "placeholder": mark_safe("in m³")}
),
label="<b>#</b> Quantity of Other Material to be Remove",
)