Skip to content

Commit

Permalink
Make Lookup object properly booled
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirbright committed Jan 9, 2016
1 parent e1f40b0 commit 8bef804
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion django_filters/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ def __init__(self, *args, **kwargs):
super(TimeRangeField, self).__init__(fields, *args, **kwargs)


Lookup = namedtuple('Lookup', ('value', 'lookup_type'))
class Lookup(namedtuple('Lookup', ('value', 'lookup_type'))):
# python nature is test __len__ on tuple types for boolean check
def __len__(self):
if not self.value:
return 0
return 2


class LookupTypeField(forms.MultiValueField):
Expand Down

0 comments on commit 8bef804

Please sign in to comment.