-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fixed #5363 -- HTML5 datetime-local valid format HTMLFormRenderer #9365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hi @auvipy! Following your comment on #5363 (comment) I ask if you could do the review! Thank you! |
rest_framework/renderers.py
Outdated
# The format of an input type="datetime-local" is "yyyy-MM-ddThh:mm" | ||
# followed by optional ":ss" or ":ss.SSS", so remove [milli|micro]seconds | ||
# to avoid browser error. | ||
field.value = "".join(field.value.rstrip('Z').split(".")[:1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The millisecond part should be retained, as it's a valid part of the format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally did it! Thanks for the pacience!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address the review comment
Thanks @auvipy! I'll do it! |
Just an update here. I'm still active! I'll do as soon as possible |
class TestDateTimeFieldHTMLFormRender(TestCase): | ||
def test_datetime_field_rendering(self): | ||
class TestSerializer(serializers.Serializer): | ||
appointment = serializers.DateTimeField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Liked this anonymous class 👍🏻
I finally did it, sorry for the long delay! |
Description
Hi!
This PR delete everything after the first 3 digits of the miliseconds part of a
DateTimeField
input atHTMLFormRenderer
to avoid break in browsers:https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/datetime-local#try_it
refs #5363