的問題,以顯示出現與此圖像 http://i.imgur.com/oExvXVu.png獲取的外鍵關係的對象在Django
使得VendorProfile名稱,而不是VendorProfile對象出現在框中我想它。我在VendorProfile中使用PurchaseOrder的外鍵關係。 這是我在models.py代碼:
class PurchaseOrder(models.Model):
product = models.CharField(max_length=256)
vendor = models.ForeignKey('VendorProfile')
class VendorProfile(models.Model):
name = models.CharField(max_length=256)
address = models.CharField(max_length=512)
city = models.CharField(max_length=256)
這裏是我的admin.py代碼:
class PurchaseOrderAdmin(admin.ModelAdmin):
fields = ['product', 'dollar_amount', 'purchase_date','vendor', 'notes']
list_display = ('product','vendor', 'price', 'purchase_date', 'confirmed', 'get_po_number', 'notes')
所以,我怎麼才能得到它在這兩個領域顯示VendorProfile的「名字」和list_display?