From b70a68777709ecca75963cc03f273ee013a3eb3a Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Wed, 21 Jun 2006 04:13:48 +0000 Subject: [PATCH] Fixed #2031 -- Don't try to remove microseconds on date objects (only datetime) for MySQL. Refs #316. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3183 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 720737efcf..bc6042ae59 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -475,7 +475,7 @@ class DateTimeField(DateField): if value is not None: # MySQL will throw a warning if microseconds are given, because it # doesn't support microseconds. - if settings.DATABASE_ENGINE == 'mysql': + if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): value = value.replace(microsecond=0) value = str(value) return Field.get_db_prep_save(self, value)