Skip to content

Commit b0d686a

Browse files
author
Ryan P Kilby
committed
Add existence check for related isnull filter
1 parent 68efb74 commit b0d686a

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
@@ -79,8 +79,9 @@ def __init__(self, *args, **kwargs):
7979
filter_.setup_filterset()
8080

8181
# Add an 'isnull' filter to allow checking if the relation is empty.
82-
isnull_filter = filters.BooleanFilter(name=("%s%sisnull" % (filter_.name, LOOKUP_SEP)))
83-
self.filters['%s%s%s' % (filter_.name, LOOKUP_SEP, 'isnull')] = isnull_filter
82+
isnull = "%s%sisnull" % (filter_.name, LOOKUP_SEP)
83+
if isnull not in self.filters:
84+
self.filters[isnull] = filters.BooleanFilter(name=isnull)
8485

8586
def get_filters(self):
8687
"""

0 commit comments

Comments
 (0)