38
votes

How 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()

Im Admin.py

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

2 Answers

57
votes

I guess you should use short_description attribute. Django-admin

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

change your model and verbose_name parametr to field. I change "author" label to "Author(s)"

models.py

class books(models.Model):
    title = models.CharField(max_length = 250)
    author= models.CharField(max_length = 250, verbose_name='Author(s)')

or simply

author      = models.CharField('Author(s)',max_length = 250)