Django - 自定义表字段的 help_text 文本内容
class GoodsForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(GoodsForm, self).__init__(*args, **kwargs) goods_obj = Goods.objects.order_by('-paixu').first() if goods_obj: self.fields['paixu'].help_text = "越大越靠前, 当前商品排序最大值为: %s" % goods_obj.paixu self.fields['is_show'].help_text = format_html('<p style="color: red;">请注意该选项 !</p>') class Meta: model = Goods exclude = () @admin.register(Goods) class DianPuAdmin(admin.ModelAdmin): list_display = ["id", "mingcheng", "paixu", "create_time"] form = GoodsForm