1234567891011121314151617 |
- from django.forms import ModelForm
- from django.core.exceptions import ValidationError
- from .models import Payment
- class PaymentForm(ModelForm):
- class Meta:
- model = Payment
- fields = ['amount', 'period', 'payment_method', 'start']
- def clean_start(self):
- start = self.cleaned_data['start']
- if self.instance.pk:
- if start < self.instance.start:
- raise ValidationError(_('Invalid value'), code='invalid')
- return start
|