我有一个带有的模型property,它返回布尔值,我想在Django模型管理中将其显示为图标。
class Foo(models.Model):
bar = models.TextField("Title", null=True, blank=True)
@property
def is_new_bar(self):
return bar == 'NEW'
Run Code Online (Sandbox Code Playgroud)
class FooAdmin(admin.ModelAdmin):
list_display = ('bar', 'is_new_bar') # is_new_bar is shown as True/False text, I want this as bool icon of django.
Run Code Online (Sandbox Code Playgroud)