Changeset 4105
- Timestamp:
- 11/25/06 20:38:04 (2 years ago)
- Files:
-
- django/trunk/django/db/models/fields/__init__.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/fields/__init__.py
r4036 r4105 458 458 def get_db_prep_save(self, value): 459 459 # Casts dates into string format for entry into database. 460 if isinstance(value, datetime.datetime): 461 value = value.date().strftime('%Y-%m-%d') 462 elif isinstance(value, datetime.date): 460 if value is not None: 463 461 value = value.strftime('%Y-%m-%d') 464 462 return Field.get_db_prep_save(self, value) … … 490 488 def get_db_prep_save(self, value): 491 489 # Casts dates into string format for entry into database. 492 if isinstance(value, datetime.datetime):490 if value is not None: 493 491 # MySQL will throw a warning if microseconds are given, because it 494 492 # doesn't support microseconds. … … 496 494 value = value.replace(microsecond=0) 497 495 value = str(value) 498 elif isinstance(value, datetime.date):499 # MySQL will throw a warning if microseconds are given, because it500 # doesn't support microseconds.501 if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):502 value = datetime.datetime(value.year, value.month, value.day, microsecond=0)503 value = str(value)504 505 496 return Field.get_db_prep_save(self, value) 506 497
