Hello everyone,
I’m getting this error - ‘“” value has an invalid date format. It must be in YYYY-MM-DD format.’ -
I tried DateTimeField instead of DateField but still I have that kind of error. Do you have any idea how to fix it?
Thanks in advance.
models.py
class Samples(models.Model):
last_extraction_date = models.DateField(null=True, blank=True)
inactivation_date = models.DateField(null=True, blank=True)
transfer_date = models.DateField(null=True, blank=True)
views.py
def addsample_row(request):
if request.method == "POST":
if (request.POST.get('last_extraction_date') or request.POST.get('last_extraction_date') is '') \
and (request.POST.get('inactivation_date') or request.POST.get('inactivation_date') is '') \
and (request.POST.get('transfer_date') or request.POST.get('transfer_date') is ''):
sample = Samples()
sample.last_extraction_date = request.POST.get('last_extraction_date')
sample.inactivation_date = request.POST.get('inactivation_date')
sample.transfer_date = request.POST.get('transfer_date')
sample.save()
messages.success(request, "New sample is added successfully!")
return HttpResponseRedirect("/")
else:
return render(request, 'addsample.html')