0

I have in admin.py:

class PurchaseOrderAdmin(admin.ModelAdmin):
    fields = ['product', 'dollar_amount']

in models.py

class PurchaseOrder(models.Model):
    product = models.CharField(max_length=256)
    dollar_amount = models.FloatField()

I would like to display 'dollar_amount' as 'price'. How would I do that?

Mdjon26
  • 2,145
  • 4
  • 19
  • 29

2 Answers2

1

Set verbose_name on the dollar_amount field to "price."

Edit:

class PurchaseOrder(models.Model):
    product = models.CharField(max_length=256)
    dollar_amount = models.FloatField(verbose_name='Price')
garnertb
  • 9,454
  • 36
  • 38
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')
drabo2005
  • 1,076
  • 1
  • 10
  • 16