장고 date가 'null' 로 들어가서 나는 에러 해결
에러메세지:
[2024-07-02 17:48:25,232] INFO [machinesiteapp.views:273] [user:super(super) app:F] site edit false : {'site_build_date': [ErrorDetail(string='Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].', code='invalid')], 'audit_start_date': [ErrorDetail(string='Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].', code='invalid')], 'audit_end_date': [ErrorDetail(string='Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].', code='invalid')], 'year': [ErrorDetail(string='A valid integer is required.', code='invalid')]}
해결방법:
else :
for key, value in data.items():
if key in ['site_build_date', 'code', 'audit_start_date', 'employee_list', 'audit_end_date', 'year']:
if value == 'null':
data[key] = None
report_form = get_object_or_404(MachineReportForm, id = int(data['form_id']))
site_serializer = MachineSiteEditSerializer(report_form.site_edit, data=data, partial=True)
'Django 장고' 카테고리의 다른 글
413 Request Entity Too Large 에러 (0) | 2024.11.12 |
---|---|
원투매니에서 발생하는 플러스원 이슈 (1) | 2024.10.24 |
장고 no reload로 키기 (0) | 2024.09.11 |
foreign key를 null=true로 했는데 Column 'form_id' cannot be null이 나온다(mac) (0) | 2024.06.26 |
mysql접속할 수 없는상태에서 비밀번호 변경 (0) | 2024.06.26 |