[Answer]-Django: rendering a template field containing html in selector choices

1👍

Use mark_safe function to make Django do not escape string in template

from django.utils.safestring import mark_safe
from django.db import models
class Test(models.Model):
    area = models.FloatField(choices=((0, mark_safe('0 mm²')), (0.5, mark_safe('0.5 mm²'))), default=0)
👤exslim

Leave a comment