mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #7448 -- Convert "in" filters to pass in the correct values for datetimes
and similar complex objects. Based on patches from cgrady and alexkosholev. Refs #7707. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7883 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -554,7 +554,7 @@ class DateField(Field):
|
||||
raise validators.ValidationError, _('Enter a valid date in YYYY-MM-DD format.')
|
||||
|
||||
def get_db_prep_lookup(self, lookup_type, value):
|
||||
if lookup_type == 'range':
|
||||
if lookup_type in ('range', 'in'):
|
||||
value = [smart_unicode(v) for v in value]
|
||||
elif lookup_type in ('exact', 'gt', 'gte', 'lt', 'lte') and hasattr(value, 'strftime'):
|
||||
value = value.strftime('%Y-%m-%d')
|
||||
@@ -641,7 +641,7 @@ class DateTimeField(DateField):
|
||||
return Field.get_db_prep_save(self, value)
|
||||
|
||||
def get_db_prep_lookup(self, lookup_type, value):
|
||||
if lookup_type == 'range':
|
||||
if lookup_type in ('range', 'in'):
|
||||
value = [smart_unicode(v) for v in value]
|
||||
else:
|
||||
value = smart_unicode(value)
|
||||
@@ -720,7 +720,7 @@ class DecimalField(Field):
|
||||
return super(DecimalField, self).get_db_prep_save(value)
|
||||
|
||||
def get_db_prep_lookup(self, lookup_type, value):
|
||||
if lookup_type == 'range':
|
||||
if lookup_type in ('range', 'in'):
|
||||
value = [self._format(v) for v in value]
|
||||
else:
|
||||
value = self._format(value)
|
||||
@@ -1097,7 +1097,7 @@ class TimeField(Field):
|
||||
return smart_unicode(value)
|
||||
else:
|
||||
prep = smart_unicode
|
||||
if lookup_type == 'range':
|
||||
if lookup_type in ('range', 'in'):
|
||||
value = [prep(v) for v in value]
|
||||
else:
|
||||
value = prep(value)
|
||||
|
||||
Reference in New Issue
Block a user