Code

Ticket #2031: mysql_microsecond.2.patch

File mysql_microsecond.2.patch, 676 bytes (added by jason@…, 8 years ago)

Fixed typo in comment.

  • django/db/models/fields/__init__.py

     
    472472        if value is not None: 
    473473            # MySQL will throw a warning if microseconds are given, because it 
    474474            # doesn't support microseconds. 
    475             if settings.DATABASE_ENGINE == 'mysql': 
     475            if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'): 
    476476                value = value.replace(microsecond=0) 
    477477            value = str(value) 
    478478        return Field.get_db_prep_save(self, value)