#8962 closed Uncategorized (fixed)
Make `input_formats` and `format` work consistently across `date`, `datetime`, and `time` fields and widgets.
Reported by: | Tai Lee | Owned by: | Karen Tracey |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | datetime format widget i18n-rf |
Cc: | real.human@…, David Larlet | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, there are some inconsistencies in what form fields and widgets we have available for date
, datetime
, and time
data. There are also inconsistencies in how the format
argument applies to the widgets, and the input_formats
applies to the fields.
DateTimeInput
andTimeInput
exist,DateInput
doesn't.DateTimeInput
acceptsformat
, butTimeInput
doesn't.SplitDateTimeField
doesn't useSplitDateTimeWidget
by default.SplitDateTimeField
doesn't allow the user to specifyinput_formats
.SplitDateTimeWidget
uses twoTextInput
widgets, instead ofTimeInput
and the missingDateInput
(and thus doesn't allow the user to specifyformats
).django.contrib.localflavor.generic.forms
is missingSplitDateTimeField
.- The documentation is sparse on detail for
SplitDateTimeField
,DateTimeInput
andTimeInput
.
This patch:
- Adds
DateInput
, which acceptsformat
, and is used forDateField
by default. - Adds
format
as an argument toTimeInput
. - Uses
SplitDateTimeWidget
forSplitDateTimeField
by default. - Adds
input_date_formats
andinput_time_formats
as arguments toSplitDateTimeField
. - Uses
DateInput
andTimeInput
forSplitDateTimeWidget
, and passes throughdate_format
andtime_format
through toDateInput
andTimeInput
asformat
, respectively. - Adds
SplitDateTimeField
todjango.contrib.localflavor.generic.forms
. - Adds documentation for all of these changes.
- Adds tests for all of these changes.
Attachments (4)
Change History (17)
by , 16 years ago
Attachment: | datetime-formatting-r8983.diff added |
---|
comment:1 by , 16 years ago
comment:2 by , 16 years ago
On second thoughts, it looks like settings.*_FORMAT
uses a slightly different format and supports some options not compatible with strftime
, etc.
by , 16 years ago
Attachment: | 8962-datetime-format-r8983.diff added |
---|
Removed redundant line from generic SplitDateTimeField
and improved documentation.
by , 16 years ago
Attachment: | 8962-datetime-format-r8983.2.diff added |
---|
Set default date/time format for SplitDateTimeWidget
as class attribute, so it can be overridden in a subclass.
comment:3 by , 16 years ago
Cc: | added |
---|
comment:4 by , 16 years ago
Cc: | added |
---|
comment:5 by , 16 years ago
Keywords: | i18n-rf added |
---|
comment:6 by , 16 years ago
Looks like SplitDateTimeField
does use SplitDateTimeWidget
by default in r9843, so I've updated the patch to work on trunk again.
comment:7 by , 16 years ago
+1 for this patch. Was bitten today with the missing format of the TimeInput widget...
comment:9 by , 16 years ago
milestone: | → 1.1 beta |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:10 by , 16 years ago
Owner: | changed from | to
---|
comment:11 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:13 by , 13 years ago
Cc: | removed |
---|---|
Easy pickings: | unset |
Severity: | → Normal |
Type: | → Uncategorized |
UI/UX: | unset |
Another option would be to use
settings.*_FORMAT
as the default if noformat
is provided. This would make it easy to configure a consistent date format across a whole site, including forms.