#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.
DateTimeInputandTimeInputexist,DateInputdoesn't.DateTimeInputacceptsformat, butTimeInputdoesn't.SplitDateTimeFielddoesn't useSplitDateTimeWidgetby default.SplitDateTimeFielddoesn't allow the user to specifyinput_formats.SplitDateTimeWidgetuses twoTextInputwidgets, instead ofTimeInputand the missingDateInput(and thus doesn't allow the user to specifyformats).django.contrib.localflavor.generic.formsis missingSplitDateTimeField.- The documentation is sparse on detail for
SplitDateTimeField,DateTimeInputandTimeInput.
This patch:
- Adds
DateInput, which acceptsformat, and is used forDateFieldby default. - Adds
formatas an argument toTimeInput. - Uses
SplitDateTimeWidgetforSplitDateTimeFieldby default. - Adds
input_date_formatsandinput_time_formatsas arguments toSplitDateTimeField. - Uses
DateInputandTimeInputforSplitDateTimeWidget, and passes throughdate_formatandtime_formatthrough toDateInputandTimeInputasformat, respectively. - Adds
SplitDateTimeFieldtodjango.contrib.localflavor.generic.forms. - Adds documentation for all of these changes.
- Adds tests for all of these changes.
Attachments (4)
Change History (17)
by , 17 years ago
| Attachment: | datetime-formatting-r8983.diff added |
|---|
comment:1 by , 17 years ago
comment:2 by , 17 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 , 17 years ago
| Attachment: | 8962-datetime-format-r8983.diff added |
|---|
Removed redundant line from generic SplitDateTimeField and improved documentation.
by , 17 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 , 17 years ago
| Cc: | added |
|---|
comment:4 by , 17 years ago
| Cc: | added |
|---|
comment:5 by , 17 years ago
| Keywords: | i18n-rf added |
|---|
comment:6 by , 17 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 , 17 years ago
+1 for this patch. Was bitten today with the missing format of the TimeInput widget...
comment:9 by , 17 years ago
| milestone: | → 1.1 beta |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:10 by , 17 years ago
| Owner: | changed from to |
|---|
comment:11 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:13 by , 14 years ago
| Cc: | removed |
|---|---|
| Easy pickings: | unset |
| Severity: | → Normal |
| Type: | → Uncategorized |
| UI/UX: | unset |
Another option would be to use
settings.*_FORMATas the default if noformatis provided. This would make it easy to configure a consistent date format across a whole site, including forms.