Merge pull request #3560 from ericholscher/fix-empty-filter

Allow HTML to render when no filter_class is defined.
This commit is contained in:
Tom Christie 2015-11-04 14:20:03 +00:00
commit 95f92e995c

View File

@ -117,8 +117,11 @@ class DjangoFilterBackend(BaseFilterBackend):
return queryset
def to_html(self, request, queryset, view):
cls = self.get_filter_class(view, queryset)
filter_instance = cls(request.query_params, queryset=queryset)
filter_class = self.get_filter_class(view, queryset)
if filter_class:
filter_instance = filter_class(request.query_params, queryset=queryset)
else:
filter_instance = None
context = Context({
'filter': filter_instance
})