Fixed #3146: DateFields no longer barf when confronted by strings. Thanks, Deepak Thukral.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6193 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2007-09-14 16:48:47 +00:00
parent f36e96cc9c
commit 42f4f44356
2 changed files with 7 additions and 1 deletions

View File

@ -278,6 +278,7 @@ answer newbie questions, and generally made Django that much better:
Frank Tegtmeyer <fte@fte.to>
thebjorn <bp@datakortet.no>
Zach Thompson <zthompson47@gmail.com>
Deepak Thukral <deep.thukral@gmail.com>
tibimicu@gmax.net
tobias@neuyork.de
Tom Tobin

View File

@ -538,7 +538,12 @@ class DateField(Field):
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if value is not None:
try:
value = value.strftime('%Y-%m-%d')
except AttributeError:
# If value is already a string it won't have a strftime method,
# so we'll just let it pass through.
pass
return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):