Ticket #1460: datefield-lookup.diff

File datefield-lookup.diff, 1.0 KB (added by Malcolm Tredinnick <malcolm@…>, 10 years ago)

Fix date comparisons in SQLite

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

     
    341341    def get_db_prep_lookup(self, lookup_type, value):
    342342        if lookup_type == 'range':
    343343            value = [str(v) for v in value]
     344        elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte', 'ne'):
     345            value = value.strftime('%Y-%m-%d')
    344346        else:
    345347            value = str(value)
    346348        return Field.get_db_prep_lookup(self, lookup_type, value)
     
    389391            value = str(value)
    390392        return Field.get_db_prep_save(self, value)
    391393
     394    def get_db_prep_lookup(self, lookup_type, value):
     395        if lookup_type == 'range':
     396            value = [str(v) for v in value]
     397        else:
     398            value = str(value)
     399        return Field.get_db_prep_lookup(self, lookup_type, value)
     400
    392401    def get_manipulator_field_objs(self):
    393402        return [forms.DateField, forms.TimeField]
    394403
Back to Top