class PurchaseOrderAdmin(admin.ModelAdmin):
fields = ['product', 'dollar_amount']
在models.py
中class PurchaseOrder(models.Model):
product = models.CharField(max_length=256)
dollar_amount = models.FloatField()
我想将'dollar_amount'显示为'价格'。我该怎么做?
答案 0 :(得分:1)
将dollar_amount字段的verbose_name设置为“price。”
修改强>
class PurchaseOrder(models.Model):
product = models.CharField(max_length=256)
dollar_amount = models.FloatField(verbose_name='Price')
答案 1 :(得分:0)
in models.py:
class PurchaseOrder(models.Model):
product = models.CharField(max_length=256)
dollar_amount = models.FloatField()
def price(self):
return self.dollar_amount
in admin.py:
class PurchaseOrderAdmin(admin.ModelAdmin):
list_display=('product','price')