summaryrefslogtreecommitdiff
path: root/django/db/models/fields/__init__.py
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2006-11-30 22:39:19 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2006-11-30 22:39:19 +0000
commit4542f21fc1b82dd0faa7be634640d2173339cb1e (patch)
tree1e0fb43c059c4c8657bb5c28fd60af051f194d92 /django/db/models/fields/__init__.py
parent3afdd8850485c9119b50a5a736d3aa16b7b912fe (diff)
generic-auth: Merged to trunk [4148].
git-svn-id: http://code.djangoproject.com/svn/django/branches/generic-auth@4149 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/fields/__init__.py')
-rw-r--r--django/db/models/fields/__init__.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index bc1eaf0a6a..8e8d68aad5 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -457,9 +457,7 @@ class DateField(Field):
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
- if isinstance(value, datetime.datetime):
- value = value.date().strftime('%Y-%m-%d')
- elif isinstance(value, datetime.date):
+ if value is not None:
value = value.strftime('%Y-%m-%d')
return Field.get_db_prep_save(self, value)
@@ -489,19 +487,12 @@ class DateTimeField(DateField):
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
- if isinstance(value, datetime.datetime):
+ 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' and hasattr(value, 'microsecond'):
value = value.replace(microsecond=0)
value = str(value)
- elif isinstance(value, datetime.date):
- # MySQL will throw a warning if microseconds are given, because it
- # doesn't support microseconds.
- if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
- value = datetime.datetime(value.year, value.month, value.day, microsecond=0)
- value = str(value)
-
return Field.get_db_prep_save(self, value)
def get_db_prep_lookup(self, lookup_type, value):