不能插入并将日期字段更新为null
err
[“''值的日期格式无效。它必须为YYYY-MM-DD格式。”]
`class StudentUserMedicalRecord(models.Model):
ImmnunBCGDateFirstDose=models.DateField(null=True, blank=True)
ImmnunBCGDateSecondDose=models.DateField(null=True, blank=True)
ImmununBCGDateThirdDose=models.DateField(null=True, blank=True)
ImmnunBCGDateBooster1=models.DateField(null=True, blank=True)
ImmnunBCGDateBooster2 = models.DateField(null=True, blank=True)
def __str__(self):
suser = '{0.Student_Users}'
return suser.format(self)
//my html
<td><input type='date' name='firstdate' /></td>
<td><input type='date' name='seconddate' /></td>
<td><input type='date' name='thirddate' /></td>
<td><input type='date' name='firstbooster' /></td>
<td><input type='date' name='secondbooster' /></td>
//my views
first = request.POST['firstdate']
second = request.POST['seconddate']
third = request.POST['thirddate']
booster = request.POST['firstbooster']
secondbooster = request.POST['secondbooster']
V_insert_data = StudentUserMedicalRecord(
ImmnunBCGDateFirstDose=first,
ImmnunBCGDateSecondDose=second,
ImmununBCGDateThirdDose=third,
ImmnunBCGDateBooster1=booster,
ImmnunBCGDateBooster2=secondbooster,
)
V_insert_data.save()