Search code examples
pythondjangodjango-modelslabeldjango-admin

How to change Django Admin Custom list field label?


How to change my_stock verbose_name?

models.py:

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

    @property
    def my_stock(self):
        return self.stock

admin.py:

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

Solution

  • I guess you should use short_description attribute. Django-admin

    def my_stock(self):
        return self.stock
    my_stock.short_description = 'Your label here'