Ticket #7707: 7707.diff

File 7707.diff, 1.6 KB (added by Alexander Koshelev, 16 years ago)

path

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

     
    554554            raise validators.ValidationError, _('Enter a valid date in YYYY-MM-DD format.')
    555555
    556556    def get_db_prep_lookup(self, lookup_type, value):
    557         if lookup_type == 'range':
     557        if lookup_type in ('range', 'in'):
    558558            value = [smart_unicode(v) for v in value]
    559559        elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte') and hasattr(value, 'strftime'):
    560560            value = value.strftime('%Y-%m-%d')
     
    641641        return Field.get_db_prep_save(self, value)
    642642
    643643    def get_db_prep_lookup(self, lookup_type, value):
    644         if lookup_type == 'range':
     644        if lookup_type in ('range', 'in'):
    645645            value = [smart_unicode(v) for v in value]
    646646        else:
    647647            value = smart_unicode(value)
  • tests/modeltests/lookup/models.py

     
    192192...
    193193TypeError: 'flat' is not valid when values_list is called with more than one field.
    194194
     195
     196# DateTimeField `in` lookups
     197>>> Article.objects.filter(pub_date__in=[datetime(2005, 7, 26), datetime(2005, 7, 28)])
     198[<Article: Article 4>, <Article: Article 1>]
     199
    195200# Every DateField and DateTimeField creates get_next_by_FOO() and
    196201# get_previous_by_FOO() methods.
    197202# In the case of identical date values, these methods will use the ID as a
Back to Top