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:
parent
f36e96cc9c
commit
42f4f44356
1
AUTHORS
1
AUTHORS
|
@ -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):
|
||||||
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:
|
||||||
|
try:
|
||||||
value = value.strftime('%Y-%m-%d')
|
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):
|
||||||
|
|
Loading…
Reference in New Issue