Skip to content

Commit

Permalink
Ammended my fix for carltongibson#115
Browse files Browse the repository at this point in the history
Instead of moving bailout code, added condition on list length, to prevent unpacking of empty list.
  • Loading branch information
augonis committed Oct 15, 2013
1 parent 356ac3c commit 52eff60
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions django_filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,15 @@ def field(self):
return self._field

def filter(self, qs, value):
if value in ([], (), {}, None, ''):
return qs

if isinstance(value, (list, tuple)):
if isinstance(value, (list, tuple)) and len(value)==2:
lookup = six.text_type(value[1])
if not lookup:
lookup = 'exact' # fallback to exact if lookup is not provided
lookup = 'exact' # fallback to exact if lookup is not provided
value = value[0]
else:
lookup = self.lookup_type

if value in ([], (), {}, None, ''):
return qs
qs = qs.filter(**{'%s__%s' % (self.name, lookup): value})
if self.distinct:
qs = qs.distinct()
Expand Down

0 comments on commit 52eff60

Please sign in to comment.