私は2つの外部キーフィールドを持つdjangoモデルを持っています。以下。これらのうちの1つは、各Lcaレコードごとに設定する必要があります。私は、MySQLのトリガと私はこれを行うことができます知っているが、あなたは、モデルのsave
方法overrideできジャンゴ2つの外部キーフィールド、ちょうど1つが値に設定され、MySQLデータベースのdjangoモデルのもう1つのヌル
class Lca(models.Model):
product = models.ForeignKey(product, null=True, blank=True)
portfolio = models.ForeignKey(portfolio, null=True, blank=True)
carbon_price = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
name = models.CharField(max_length=255, blank=True)
total_footprint = models.IntegerField(blank=True, null=True)
calculation_type = models.CharField(max_length=9)
total_cv = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
source = models.CharField(max_length=255, blank=True)
date_from = models.DateField()
date_to = models.DateField(blank=True, null=True)
def __unicode__(self):
return self.name
# end __unicode__
# end
ありがとうございました。これは働いている – MagicLAMP