简单情况,型号:
class Manufacturer(models.Model):
name = models.CharField(max_length=200)
slug = models.SlugField(max_length=200, null=True)
active = models.BooleanField()
...
和模型管理员:
class ManufacturerAdmin(admin.ModelAdmin):
search_fields = ['name']
list_filter = ['assortment_type', 'active']
ordering = ('priority',)
prepopulated_fields = {'slug':('name',),}
list_display = ('name', 'active')
仍在 Admin 活动列中显示为 True/False 而不是图标。我可以创建方法并设置 Boolean = True 属性,但我失去了对列的排序能力。很明显,我在这里遗漏了一些东西。