Code

Ticket #2993: lazydate-no-isinstance.diff

File lazydate-no-isinstance.diff, 1011 bytes (added by Bastian Kleineidam <calvin@…>, 8 years ago)
Line 
1Index: __init__.py
2===================================================================
3--- __init__.py (Revision 4066)
4+++ __init__.py (Arbeitskopie)
5@@ -459,7 +459,7 @@
6         # Casts dates into string format for entry into database.
7         if isinstance(value, datetime.datetime):
8             value = value.date().strftime('%Y-%m-%d')
9-        elif isinstance(value, datetime.date):
10+        elif value is not None:
11             value = value.strftime('%Y-%m-%d')
12         return Field.get_db_prep_save(self, value)
13 
14@@ -495,7 +495,7 @@
15             if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
16                 value = value.replace(microsecond=0)
17             value = str(value)
18-        elif isinstance(value, datetime.date):
19+        elif value is not None:
20             # MySQL will throw a warning if microseconds are given, because it
21             # doesn't support microseconds.
22             if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):