ฉันมีโมเดลแบบนี้
class Income(models.Model):
value = models.DecimalField(max_digits=10, decimal_places=2)
remitted = models.DecimalField(max_digits=10, decimal_places=2, default=0.00)
ฉันมีรูปแบบเช่นนี้
class EditIncomeForm(forms.ModelForm):
class Meta:
model = Income
fields = ("value", )
def clean_value(self):
value = self.cleaned_data["value"]
if self.value < self.remitted:
raise forms.ValidationError("Error message")
return value
ตอนนี้อยู่ในรูปแบบโมเดล ฉันจะอัปเดตค่าของฟิลด์ remitted
ได้อย่างไร ดูเหมือนว่าฉันจะไม่สามารถเข้าถึงฟิลด์ remitted
ด้วยวิธีนี้ได้ ฉันใช้ Django 2.0