Kaydet (Commit) 42f4f443 authored tarafından Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss

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
üst f36e96cc
...@@ -278,6 +278,7 @@ answer newbie questions, and generally made Django that much better: ...@@ -278,6 +278,7 @@ answer newbie questions, and generally made Django that much better:
Frank Tegtmeyer <fte@fte.to> Frank Tegtmeyer <fte@fte.to>
thebjorn <bp@datakortet.no> thebjorn <bp@datakortet.no>
Zach Thompson <zthompson47@gmail.com> Zach Thompson <zthompson47@gmail.com>
Deepak Thukral <deep.thukral@gmail.com>
tibimicu@gmax.net tibimicu@gmax.net
tobias@neuyork.de tobias@neuyork.de
Tom Tobin Tom Tobin
......
...@@ -538,7 +538,12 @@ class DateField(Field): ...@@ -538,7 +538,12 @@ class DateField(Field):
def get_db_prep_save(self, value): def get_db_prep_save(self, value):
# Casts dates into string format for entry into database. # Casts dates into string format for entry into database.
if value is not None: if value is not None:
value = value.strftime('%Y-%m-%d') 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) return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self): def get_manipulator_field_objs(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment