1👍
If you want to not apply the check when date_paid
is None
:
for instance in GratuityPayment.objects.all():
if instance.date_paid is not None and employment_number == instance.employment_number:
raise forms.ValidationError('This Employment Mumber was paid on ' + str(instance.date_paid) + '. You cannot proceed with this retirement')
But, why don’t use .filter()
and get only relevant records in the first place:
GratuityPayment.objects.filter(date_paid__isnull=False,
employment_number=employment_number)
0👍
It is actually working. Its Given None because that particular Table row did have None in the table.
I just populated the date_paid and it returned the date instead of None.
- Python multiprocessing not reducing processing time much
- Can't send email in Python/Django
- Django-datatable won't be added to INSTALLED_APPS
- ImageField url returns an empty string
- How to recursively get absolute url from parent instance(s)?
Source:stackexchange.com