如何更改Django Admin自定义列表字段标签

How to change Django Admin Custom list field label

如何更改库存详细名称?

模特儿

1
2
3
4
5
6
class Book(models.Model):
 name = models.CharField(u"Нэр", max_length = 200)

 @property
 def in_stock(self):
  return self.stocks.count()

即时通讯

1
2
3
class BookAdmin(admin.ModelAdmin):
 list_display  = ('name', 'in_stock')
 search_fields = ('name', )

我想你应该使用简短的描述属性。Django管理

1
2
3
def in_stock(self):
  return self.stocks.count()
in_stock.short_description = 'Your label here'