0
私は私が私の更新ビューできれいなロジックを複製する必要がなく、簡単な更新時に同じクリーンな方法をトリガーするにはどうすればよい更新時にモデルからクリーンメソッドをトリガーする方法は?
def clean(self):
model = self.__class__
if self.unit and (self.is_active == True) and model.objects.filter(unit=self.unit, is_terminated = False , is_active = True).exclude(id=self.id).count() > 0:
raise ValidationError('Unit has active lease already, Terminate existing one prior to creation of new one or create a not active lease '.format(self.unit))
私のモデルで定義されたデータの検証を行い、私のフォームを保存しますか?(私は私はちょうど
Unit.objects.filter(pk=term.id).update(is_active=False)
あなたはおそらく、これを行うことはできません。 –