Is there any way for django admin to display html? on the add database fields page


admin K2O

clipboard.png
using verbose_name will directly display it as text, which is not successful

found that there is a format_html () method, but it doesn"t seem to work here
can only be used on list_display ()


this method, which needs to override the parent class, makes the verbose_name tag a safe string.

class MarkSafeCharField(models.FloatField):
    def formfield(self, **kwargs):
        kwargs['label'] = mark_safe(self.verbose_name)
        return super().formfield(**kwargs)
        
-sharp 
name= MarkSafeCharField(verbose_name='K<sub>2</sub>0')

you can see what you want:

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b39c97-2c1c6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b39c97-2c1c6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?