Ticket #2993: lazydate-no-isinstance.diff

File lazydate-no-isinstance.diff, 1011 bytes (added by Bastian Kleineidam <calvin@…>, 9 years ago)
  • __init__.py

     
    459459        # Casts dates into string format for entry into database.
    460460        if isinstance(value, datetime.datetime):
    461461            value = value.date().strftime('%Y-%m-%d')
    462         elif isinstance(value, datetime.date):
     462        elif value is not None:
    463463            value = value.strftime('%Y-%m-%d')
    464464        return Field.get_db_prep_save(self, value)
    465465
     
    495495            if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
    496496                value = value.replace(microsecond=0)
    497497            value = str(value)
    498         elif isinstance(value, datetime.date):
     498        elif value is not None:
    499499            # MySQL will throw a warning if microseconds are given, because it
    500500            # doesn't support microseconds.
    501501            if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
Back to Top