mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
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:
parent
b8c9c809ff
commit
378d6a1a19
|
@ -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
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user