【发布时间】:2017-02-05 09:52:47
【问题描述】:
我有以下型号:
class Property(models.Model):
user = models.ForeignKey(User)
id = models.CharField(max_length=20, null=True)
class Property_Value(models.Model):
id = models.ForeignKey(Property)
amount = models.DecimalField(max_digits = 10, decimal_places
如何在管理页面通过 Property 访问 Property_Value.amount?
到目前为止我有这个......
class PropertyAdmin(admin.ModelAdmin):
list_display = ('id', 'user', 'property_value')
def property_value(self, obj):
return obj.id.amount
class Meta:
model = Property
admin.site.register(Property, PropertyAdmin)
【问题讨论】:
标签: django django-models django-admin django-1.9