Commit 378d6a1a by Eric Holscher

Allow HTML to render when no filter_class is defined.

Previously it required a filter_class,
or else it would error when calling `cls()`.
This now sets the `filter` context to `None`
if one does not exist.

Fixes #3559
parent b8c9c809
...@@ -118,7 +118,10 @@ class DjangoFilterBackend(BaseFilterBackend): ...@@ -118,7 +118,10 @@ class DjangoFilterBackend(BaseFilterBackend):
def to_html(self, request, queryset, view): def to_html(self, request, queryset, view):
cls = self.get_filter_class(view, queryset) cls = self.get_filter_class(view, queryset)
filter_instance = cls(request.query_params, queryset=queryset) if cls:
filter_instance = cls(request.query_params, queryset=queryset)
else:
filter_instance = None
context = Context({ context = Context({
'filter': filter_instance 'filter': filter_instance
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment