我有代码:
class PurchaseOrder(models.Model):
product = models.ManyToManyField('Product', null =True)
def get_products(self):
return "\n".join([p.products for p in self.product.all()])
class Product(models.Model):
products = models.CharField(max_length=256, null =True)
def __unicode__(self):
return self.products
在views.py中:
class PurchaseOrderAdmin(admin.ModelAdmin):
fields = ['product']
list_display = ('get_products')
这给了我这个: 但是,问题是格式非常难看。我怎样才能得到它: