How to change Django Admin Custom list field label - Stack Overflow
https://stackoverflow.com/questions/4141471/how-to-change-django-admin-custom-list-field-labelHow to change in_stock verbose_name ?
Models.py
class Book(models.Model):
name = models.CharField(u"Нэр", max_length = 200)
@property
def in_stock(self):
return self.stocks.count()
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', )
↓
def in_stock(self):
return self.stocks.count()
in_stock.short_description = 'Your label here'
class BookAdmin(admin.ModelAdmin):
list_display = ('name', 'in_stock')
search_fields = ('name', )
↓
def in_stock(self):
return self.stocks.count()
in_stock.short_description = 'Your label here'
0 件のコメント:
コメントを投稿