A form was created with the following field:
start_date = forms.DateTimeField(required=True,
widget=forms.DateTimeInput({'class': 'datetime'}))
The following POST data was passed:
start_date u'11/03/2012 00:00:00'
The following traceback was received when I check for form.is_valid() in
the view:
---
Environment:
Request Method: POST
Request URL: http://127.0.0.1:6701/reports/ondemand/Top_Incident_Types/
Django Version: 1.4.2
Python Version: 2.5.3
Installed Applications:
('django.contrib.formtools',
'django.contrib.humanize',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'mykui.accounts',
'mykui.console',
'mykui.mykonfig',
'mykui.reports',
'mykui.status',
'mykui.updates',
'mykui.util')
Installed Middleware:
('django.middleware.gzip.GZipMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'mykui.middleware.UserMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'mykui.middleware.UnavailableMiddleware',
'mykui.middleware.SystemMessageMiddleware',
'mykui.middleware.TimezoneMiddleware')
Traceback:
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/core/handlers/base.py" in
get_response
111. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/core/handlers/base.py" in
get_response
111. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/views/decorators/http.py" in inner
41. return func(request, *args, **kwargs)
File "/usr/share/msa/ui/mykui/decorators.py" in _inner
49. return view(*args, **kwargs)
File "/usr/share/msa/ui/mykui/decorators.py" in _inner
31. return view(*args, **kwargs)
File "/usr/share/msa/ui/mykui/reports/views.py" in reports_ondemand
38. if form.is_valid():
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/forms.py" in is_valid
124. return self.is_bound and not bool(self.errors)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/forms.py" in _get_errors
115. self.full_clean()
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/forms.py" in full_clean
270. self._clean_fields()
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/forms.py" in _clean_fields
287. value = field.clean(value)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/forms.py" in _clean_fields
287. value = field.clean(value)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/fields.py" in clean
153. value = self.to_python(value)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/fields.py" in to_python
437. result = super(DateTimeField, self).to_python(value)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/fields.py" in to_python
342. return self.strptime(value, format)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/fields.py" in to_python
342. return self.strptime(value, format)
File "/usr/share/msa/jython/Lib/site-
packages/Django-1.4.2-py2.5.egg/django/forms/fields.py" in strptime
441. return datetime.datetime.strptime(value, format)
File "/usr/share/msa/jython/Lib/datetime.py" in strptime
1499. return cls(*(_time.strptime(date_string, format))[0:6])
Exception Type: IllegalArgumentException at
/reports/ondemand/Top_Incident_Types/
Exception Value: java.lang.IllegalArgumentException: Illegal pattern
character 'f'
---
At 441, format = '%Y-%m-%d %H:%M:%S.%f'
The %f formatting character was introduced in Python 2.6, but it is not
supported in Jython, even in the 2.7 alphas.
http://bugs.jython.org/issue1964
I remember this code working fine in Django 1.4.1, but I cannot seem to
find a commit that would have broken it during the timeframe between the
1.4.1 and 1.4.2 releases.
--
Ticket URL: <https://code.djangoproject.com/ticket/19417>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 0
Old description:
New description:
As near as I can tell, this is a problem with Django / Jython
compatibility and not my code... if I'm wrong feel free to slap my
wrist...
A form was created with the following field:
start_date = forms.DateTimeField(required=True,
widget=forms.DateTimeInput({'class': 'datetime'}))
The following POST data was passed:
start_date u'11/03/2012 00:00:00'
The following traceback was received when I check for form.is_valid() in
the view:
{{{
Environment:
At 441, format = '%Y-%m-%d %H:%M:%S.%f'
The %f formatting character was introduced in Python 2.6, but it is not
supported in Jython, even in the 2.7 alphas.
http://bugs.jython.org/issue1964
I remember this code working fine in Django 1.4.1, but I cannot seem to
find a commit that would have broken it during the timeframe between the
1.4.1 and 1.4.2 releases.
--
Comment:
This behavior was introduced by the fix for #9459.
--
Ticket URL: <https://code.djangoproject.com/ticket/19417#comment:1>
* type: Uncategorized => Bug
* stage: Unreviewed => Design decision needed
Comment:
Given that this is a known bug in Jython, I'm not sure what the right
response is here. The %f is needed to fix the problem from #9459; the
right solution would seem to be "Fix Jython", not "put in a workaround in
Django".
--
Ticket URL: <https://code.djangoproject.com/ticket/19417#comment:2>
Comment (by fvox13):
I agree that Jython is the right place to put the fix. However, as it
stands right now, our documentation is wrong, because it states that we
are compatible with Jython 2.5, when we're not. Some mention of this bug
should appear here: https://docs.djangoproject.com/en/1.4/howto/jython/
especially given how common DateTimeField usage is.
--
Ticket URL: <https://code.djangoproject.com/ticket/19417#comment:3>
* stage: Design decision needed => Accepted
Comment:
Accepting as a doc fix.
--
Ticket URL: <https://code.djangoproject.com/ticket/19417#comment:4>
* component: Forms => Documentation
--
Ticket URL: <https://code.djangoproject.com/ticket/19417#comment:5>
* status: new => closed
* resolution: => duplicate
Comment:
Marking as a duplicate of #20517 which suggests documenting Jython issues
on a wiki page. I've made a note of this issue on that ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/19417#comment:6>