Code

Opened 3 years ago

Closed 3 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:

Description

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

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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
False
>>> 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 3 years ago by ramiro

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #14294.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.