Opened 7 years ago

Closed 7 years ago

#15135 closed (duplicate)

Default input_formats for forms.DateField not as documented

Reported by: Aryeh Leib Taurog <vim@…> Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: vim@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


There seem to be significantly fewer default date input formats than are listed in the forms.DateField documentation.

In [5]: from django.utils import formats
In [6]: formats.get_format('DATE_INPUT_FORMATS')
Out[6]: ('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y')

I don't know if this is a bug in the documentation or the l10n (I hope it's the latter).

Change History (2)

comment:1 Changed 7 years ago by Karen Tracey

Triage Stage: UnreviewedAccepted

That doc is a bit out-of-date in that it does not take into account localization. If USE_L10N is True, then your default date input formats are determined by the locale, and yes, the default input formats when using localization support are not as many as shown in that doc. (As for why see #13339.)

If USE_L10N is False, you get the defaults listed in the doc:

>>> import django
>>> django.get_version()
u'1.3 beta 1 SVN-15254'
>>> from django.utils import formats
>>> from django.conf import settings
>>> settings.USE_L10N
>>> formats.get_format('DATE_INPUT_FORMATS')
('%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %
Y', '%d %B, %Y')

I think the referenced documentation needs to be updated to mention that that "default" is only the default in cases where USE_L10N is False, and probably point to the L10N docs for more info on what the default is when localization support is being used.

comment:2 Changed 7 years ago by Ramiro Morales

Resolution: duplicate
Status: newclosed

Duplicate of #14294.

Note: See TracTickets for help on using tickets.
Back to Top