K
K
Konstantin Malyarov2018-04-17 13:46:19
Django
Konstantin Malyarov, 2018-04-17 13:46:19

"The value '' has an invalid date format. It must be in the format YYYY-MM-DD."?

What is this meaning ''?
In models:

exit_day = models.DateField(default=None, blank=True, null=True)
    exit_time = models.TimeField(default=None, blank=True, null=True)
    period = models.IntegerField(default=None, null=True)

In the shape of:
exit_day = forms.CharField(label='Дата выписки',
                               widget=forms.TextInput(attrs={'class': 'form-control col-2', 'type': 'date'}),
                               required=False)
    exit_time = forms.CharField(label='Время выписки',
                                widget=forms.TextInput(attrs={'class': 'form-control col-2', 'type': 'time'}),
                                required=False)
    period = forms.CharField(label='Проведено койко-дней',
                             widget=forms.TextInput(attrs={'class': 'form-control col-1'}), required=False)

In views:
def patient_history_f003yStr1_edit(request, patient, disease_history):
    if request.user.is_authenticated:
        patient = Patient.objects.get(pk=patient)
        current_history = Disaese_history.objects.get(pk=disease_history, patient=patient)
        form_f003_1 = F003yStr1.objects.get(patient=patient, disease_history=current_history)
        form_f003yStr1 = Form_f003yStr1(request.POST or None, instance=form_f003_1)
        if request.POST and form_f003yStr1.is_valid():
            form_f003yStr1.save()
        return render(request, 'disease_history/form_003y/str1.html', locals())
    else:
        return redirect('login')

Error when saving:
5ad5d041a45a9094952327.png
If you add lines:
form = form_f003yStr1.save(commit=False)
            form.exit_day = None
            form.exit_time = None
            form.period = None
            form.save()

That all works.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question