Skip to content

Commit 2b3a1f6

Browse files
committed
Merge pull request #33 from rpkilby/isnull-check
Add existence check for related isnull filter
2 parents 92cfdf6 + b0d686a commit 2b3a1f6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

rest_framework_filters/filterset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ def __init__(self, *args, **kwargs):
6969
filter_.setup_filterset()
7070

7171
# Add an 'isnull' filter to allow checking if the relation is empty.
72-
isnull_filter = filters.BooleanFilter(name=("%s%sisnull" % (filter_.name, LOOKUP_SEP)))
73-
self.filters['%s%s%s' % (filter_.name, LOOKUP_SEP, 'isnull')] = isnull_filter
72+
isnull = "%s%sisnull" % (filter_.name, LOOKUP_SEP)
73+
if isnull not in self.filters:
74+
self.filters[isnull] = filters.BooleanFilter(name=isnull)
7475

7576
def get_filters(self):
7677
"""

0 commit comments

Comments
 (0)