Default datetime input to seconds granularity

This commit is contained in:
Christopher C. Wells 2023-04-15 12:58:41 -07:00
parent 8211cb40a8
commit 2007f998cf
1 changed files with 7 additions and 0 deletions

View File

@ -116,6 +116,13 @@ class DateTimeBaseInput(widgets.DateTimeBaseInput):
class DateTimeInput(DateTimeBaseInput): class DateTimeInput(DateTimeBaseInput):
input_type = "datetime-local" input_type = "datetime-local"
def build_attrs(self, base_attrs, extra_attrs=None):
attrs = super().build_attrs(base_attrs, extra_attrs)
# Default to seconds granularity. Required for client validation in Safari.
if "step" not in attrs:
attrs["step"] = 1
return attrs
class DateInput(DateTimeBaseInput): class DateInput(DateTimeBaseInput):
input_type = "date" input_type = "date"