Что это за значение такое
''
?
В моделях:
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)
В форме:
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)
В 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')
При сохранении ошибка:
Если добавить строчки:
form = form_f003yStr1.save(commit=False)
form.exit_day = None
form.exit_time = None
form.period = None
form.save()
То все работает.