DateField and DateTimeField should take empty string "" as null #9773
Unanswered
curoa
asked this question in
Ideas & Suggestions
Replies: 1 comment
-
At first glance, that sounds like a reasonable change to me, but I worry/wonder about why it was done this way in the first place. Can't the front-end library do some mapping there where empty is always sent as null? Or is it because the request content type is form-data and not JSON?
You may get a smaller/more targeted patch by creating a custom |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I using DatePicker from '@mui/x-date-pickers'.
Because html input can't handle null,
so DatePicker sends empty string if date value is null.
However DRF raise Error as empty string is not suit for format for DateField and DateTimeField.
I think it is useful that DateField and DateTimeField can take empty string as null.
Some people think too.
ref. https://stackoverflow.com/questions/46871046/post-empty-date-field-error-with-django-rest-framework
I created my ModelSerializer so that you don't have to specify the field name every time.
Beta Was this translation helpful? Give feedback.
All reactions