Opened 16 years ago

Closed 15 years ago

Last modified 12 years ago

#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.

  1. DateTimeInput and TimeInput exist, DateInput doesn't.
  2. DateTimeInput accepts format, but TimeInput doesn't.
  3. SplitDateTimeField doesn't use SplitDateTimeWidget by default.
  4. SplitDateTimeField doesn't allow the user to specify input_formats.
  5. SplitDateTimeWidget uses two TextInput widgets, instead of TimeInput and the missing DateInput (and thus doesn't allow the user to specify formats).
  6. django.contrib.localflavor.generic.forms is missing SplitDateTimeField.
  7. The documentation is sparse on detail for SplitDateTimeField, DateTimeInput and TimeInput.

This patch:

  1. Adds DateInput, which accepts format, and is used for DateField by default.
  2. Adds format as an argument to TimeInput.
  3. Uses SplitDateTimeWidget for SplitDateTimeField by default.
  4. Adds input_date_formats and input_time_formats as arguments to SplitDateTimeField.
  5. Uses DateInput and TimeInput for SplitDateTimeWidget, and passes through date_format and time_format through to DateInput and TimeInput as format, respectively.
  6. Adds SplitDateTimeField to django.contrib.localflavor.generic.forms.
  7. Adds documentation for all of these changes.
  8. Adds tests for all of these changes.

Attachments (4)

datetime-formatting-r8983.diff (13.8 KB ) - added by Tai Lee 16 years ago.
8962-datetime-format-r8983.diff (14.4 KB ) - added by Tai Lee 16 years ago.
Removed redundant line from generic SplitDateTimeField and improved documentation.
8962-datetime-format-r8983.2.diff (14.6 KB ) - added by Tai Lee 16 years ago.
Set default date/time format for SplitDateTimeWidget as class attribute, so it can be overridden in a subclass.
8962-datetime-format-r9843.diff (14.4 KB ) - added by Tai Lee 15 years ago.
Updated to r9843.

Download all attachments as: .zip

Change History (17)

by Tai Lee, 16 years ago

comment:1 by Tai Lee, 16 years ago

Another option would be to use settings.*_FORMAT as the default if no format is provided. This would make it easy to configure a consistent date format across a whole site, including forms.

comment:2 by Tai Lee, 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 Tai Lee, 16 years ago

Removed redundant line from generic SplitDateTimeField and improved documentation.

by Tai Lee, 16 years ago

Set default date/time format for SplitDateTimeWidget as class attribute, so it can be overridden in a subclass.

comment:3 by Thomas Güttler, 15 years ago

Cc: hv@… added

comment:4 by David Larlet, 15 years ago

Cc: David Larlet added

comment:5 by Marc Garcia, 15 years ago

Keywords: i18n-rf added

by Tai Lee, 15 years ago

Updated to r9843.

comment:6 by Tai Lee, 15 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 Claude Paroz, 15 years ago

+1 for this patch. Was bitten today with the missing format of the TimeInput widget...

comment:8 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:9 by Jacob, 15 years ago

milestone: 1.1 beta
Triage Stage: UnreviewedAccepted

comment:10 by Karen Tracey, 15 years ago

Owner: changed from nobody to Karen Tracey

comment:11 by Karen Tracey, 15 years ago

Resolution: fixed
Status: newclosed

(In [10115]) Fixed #8962 -- Consistently support format and input_format in the various (individual, combined, split) date and time form fields and widgets.

Many thanks to Tai Lee for doing all the work here.

comment:12 by Jacob, 12 years ago

milestone: 1.1 beta

Milestone 1.1 beta deleted

comment:13 by Thomas Güttler, 12 years ago

Cc: hv@… removed
Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset
Note: See TracTickets for help on using tickets.
Back to Top