【发布时间】:2015-06-02 03:51:36
【问题描述】:
我想用计算字段保存 django 模型,以便我可以对其应用搜索。
class TestModel(models.Model):
x = models.CharField(max_length=16)
z = models.CharField(max_length=16)
# I want a field like below and also saves in databse
# computed = computed()
def computed(self):
result = self.x + self.y
return result
【问题讨论】:
标签: python django django-models