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
This commit is contained in:
Eric Holscher 2015-10-28 12:37:19 -07:00
parent b8c9c809ff
commit 378d6a1a19

View File

@ -118,7 +118,10 @@ class DjangoFilterBackend(BaseFilterBackend):
def to_html(self, request, queryset, view):
cls = self.get_filter_class(view, queryset)
if cls:
filter_instance = cls(request.query_params, queryset=queryset)
else:
filter_instance = None
context = Context({
'filter': filter_instance
})