Changeset 3960
- Timestamp:
- 11/02/06 08:24:31 (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
r3851 r3960 458 458 def get_db_prep_save(self, value): 459 459 # Casts dates into string format for entry into database. 460 if value is not None: 460 if isinstance(value, datetime.datetime): 461 value = value.date().strftime('%Y-%m-%d') 462 elif isinstance(value, datetime.date): 461 463 value = value.strftime('%Y-%m-%d') 462 464 return Field.get_db_prep_save(self, value) … … 488 490 def get_db_prep_save(self, value): 489 491 # Casts dates into string format for entry into database. 490 if value is not None:492 if isinstance(value, datetime.datetime): 491 493 # MySQL will throw a warning if microseconds are given, because it 492 494 # doesn't support microseconds. … … 494 496 value = value.replace(microsecond=0) 495 497 value = str(value) 498 elif isinstance(value, datetime.date): 499 # MySQL will throw a warning if microseconds are given, because it 500 # 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 496 505 return Field.get_db_prep_save(self, value) 497 506
