#14658: DateField initial does not honor locale, against documentation
-------------------+--------------------------------------------------------
Reporter: intgr | Owner: nobody
Status: new | Milestone:
Component: Forms | Version: 1.2
Keywords: | Stage: Unreviewed
Has_patch: 0 |
-------------------+--------------------------------------------------------
The documentation at
http://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.Field.initial
suggests that when passing the `intial=` argument to Date``Field, it's
converted to the locale date format:
{{{
>>> import datetime
>>> class DateForm(forms.Form):
... day = forms.DateField(initial=datetime.date.today)
>>> print DateForm()
<tr><th>Day:</th><td><input type="text" name="day" value="12/23/2008"
/><td></tr>
}}}
Notice that `value="12/23/2008"` is localized.
However, this does not seem to work in practice:
{{{
In [1]: from django import forms
In [2]: import datetime
In [3]: class DateForm(forms.Form):
...: day = forms.DateField(initial=datetime.date.today)
In [4]: print DateForm()
<tr><th><label for="id_day">Day:</label></th><td><input type="text"
name="day" value="2010-11-10" id="id_day" /></td></tr>
}}}
Notice above `value="2010-11-10"` -- it behaves this way in both Django
1.2.3 and in trunk.
Compare this to what the templater uses with its `|date` filter:
{{{
In [10]: from django.template import Template, Context
In [11]: t=Template("{{ foo|date }}")
In [12]: t.render(Context({'foo': datetime.date.today()}))
Out[12]: u'10.11.2010'
In [13]: from django.conf import settings
In [14]: settings.DATE_FORMAT
Out[14]: 'd.m.Y'
In [15]: settings.DATETIME_FORMAT
Out[15]: 'd.m.Y H:M:s'
In [16]: settings.USE_L10N
Out[16]: True
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/14658>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.