Skip to content

Commit

Permalink
BaseFilterSet sync: add request and is_valid
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed May 27, 2020
1 parent 40b5f21 commit c00a54e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions django_mongoengine_filter/filterset.py
Expand Up @@ -197,6 +197,7 @@ def __init__(
self,
data=None,
queryset=None,
request=None,
prefix=None,
strict=None,
*args,
Expand All @@ -208,6 +209,7 @@ def __init__(
queryset = self._meta.model.objects
self.queryset = queryset
self.form_prefix = prefix
self.request = request
if strict is not None:
self.strict = strict

Expand All @@ -231,6 +233,12 @@ def __len__(self):
def __getitem__(self, key):
return self.qs[key]

def is_valid(self):
"""
Return True if the underlying form has no errors, or False otherwise.
"""
return self.is_bound and self.form.is_valid()

@property
def qs(self):
if not hasattr(self, "_qs"):
Expand Down

0 comments on commit c00a54e

Please sign in to comment.