klipstein/dojango — Issue #13: 13 - ValidationError on empty DateInput field 
Author: klipstein
Created: 2011-11-06 12:46:22+00:00
State: closed

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/panel/handbook/tournament/2/
Django Version: 1.1 beta 1 SVN-10980
Python Version: 2.5.4
Installed Applications:
['localeurl',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.flatpages',
'multilingual',
'multilingual.flatpages',
'dojango']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'localeurl.middleware.LocaleURLMiddleware',
'multilingual.middleware.DefaultLanguageMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')

Traceback:
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
92. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python25\lib\site-packages\django\contrib\auth\decorators.py" in
__call__
78. return self.view_func(request, *args, **kwargs)
File "C:\Python25\lib\site-packages\annoying\decorators.py" in wrapper
55. output = function(request, *args, **kwargs)
File "C:\prog\www\gobase\panel\views.py" in tournament
290.	tournament.save()
File "C:\Python25\lib\site-packages\django\db\models\base.py" in save
410. self.save_base(force_insert=force_insert,
force_update=force_update)
File "C:\Python25\lib\site-packages\django\db\models\base.py" in save_base
474. rows = manager.filter(pk=pk_val)._update(values)
File "C:\Python25\lib\site-packages\django\db\models\query.py" in _update
442. query.add_update_fields(values)
File "C:\Python25\lib\site-packages\django\db\models\sql\subqueries.py" in
add_update_fields
245. val = field.get_db_prep_save(val)
File "C:\Python25\lib\site-packages\django\db\models\fields\__init__.py" in
get_db_prep_save
192. return self.get_db_prep_value(value)
File "C:\Python25\lib\site-packages\django\db\models\fields\__init__.py" in
get_db_prep_value
511. return connection.ops.value_to_db_date(self.to_python(value))
File "C:\Python25\lib\site-packages\django\db\models\fields\__init__.py" in
to_python
474. _('Enter a valid date in YYYY-MM-DD format.'))

Exception Type: ValidationError at /panel/handbook/tournament/2/
Exception Value: Enter a valid date in YYYY-MM-DD format.

-------------------------------------
class Tournament(models.Model):
...
end_date = models.DateField(_("End date"), blank=True, null=True)
...

POST
Variable	Value
status	u'1'
city	u'1'
play_time_ru	u'1 \u0447\u0430\u0441'
referee	u'1'
end_date	u''
rules	u'1'
country	u'1'
region	u'1'
title_en	u'2 proba'
system	u'1'
boyomi	u'10/20'
tour_count	u'4'
komi	u'6.5'
title_ru	u'2 \u043f\u0440\u043e\u0431\u0430'
play_time_en	u'1 ttt'
player_display	u'1'
start_date	u'2009-06-12'

Original link: http://code.google.com/p/dojango/issues/detail?id=13