Ticket #5223: sqlite_year_lookup_fix.diff

File sqlite_year_lookup_fix.diff, 752 bytes (added by Manuel Saelices <msaelices@…>, 17 years ago)

A patch that fixes sqlite year lookup

  • models/fields/__init__.py

     
    507507            value = value.strftime('%Y-%m-%d')
    508508        else:
    509509            value = smart_unicode(value)
     510        if lookup_type == 'year' and settings.DATABASE_ENGINE == 'sqlite3':
     511            try:
     512                value = int(value)
     513            except ValueError:
     514                raise ValueError("The __year lookup type requires an integer argument")
     515            return ['%s-01-01' % value, '%s-12-31' % value]
    510516        return Field.get_db_prep_lookup(self, lookup_type, value)
    511517
    512518    def pre_save(self, model_instance, add):
Back to Top