我希望在使用django的model admin保存模型时填充/设置另一个模型的值。我无法重写模型窗体的save方法来执行此操作。我能得到这个的一些示例代码吗。Django 1.3。示例代码如下:
你知道吗型号.py地址:
class Customer(models.Model):
name = models.CharField(max_length=100, unique=True)
active = models.BooleanField()
class Branch(models.Model):
customer = models.ForeignKey(Customer)
name = models.CharField(max_length=100)
class Service(models.Model):
branch = models.ForeignKey(Branch, blank=True, null=True)
AMC_start_date
AMC_expiry_date
other fields...
在管理员.py,在保存服务实例时,在比较AMC到期日期和当前日期时,我想将customer status的值设置为active/not。我该怎么做?我使用ServiceForm的模型表单。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐