diff options
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | django/db/models/fields/__init__.py | 7 |
2 files changed, 7 insertions, 1 deletions
@@ -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): |
