summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2007-09-14 16:48:47 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2007-09-14 16:48:47 +0000
commit42f4f44356044ee57b7efd32a423c01e2b9454bc (patch)
tree6577b17e12bde997ff1ad09ec148e05a54c1578d
parentf36e96cc9c6c1e99fb55cfc6940f04fa9a7c86ff (diff)
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
-rw-r--r--AUTHORS1
-rw-r--r--django/db/models/fields/__init__.py7
2 files changed, 7 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index cb69ebd0b0..1e56bd3412 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -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
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 795f8936bd..3792a30a88 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -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:
- 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)
def get_manipulator_field_objs(self):