2010-11-10 122 views
19

如何更改in_stock verbose_name?如何更改Django Admin自定義列表字段標籤

Models.py

class Book(models.Model): 
name = models.CharField(u"Нэр", max_length = 200) 

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

林Admin.py

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

回答

28

我猜你應該使用SHORT_DESCRIPTION屬性。 Django-admin

def in_stock(self): 
    return self.stocks.count() 
in_stock.short_description = 'Your label here' 
相關問題