假设我有这个模型:models.py
class Tool:
name = models.CharField()
price = models.DecimalField()
class Storage:
tool = models.ForeignKey('tools')
count = models.Integerfield()
然后在 datagrids.py
class StorageDataGrid(DataGrid):
tool = Column()
count = Column()
price = ?
def __init__(self, request):
DataGrid.__init__(self, request, queryset=Storage.objects.all())
self.default_columns = ['tool', 'count', 'price']
问题是,如何定义价格列。或者如何将它放在查询集中。