-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow HTML to render when no filter_class is defined. #3560
Conversation
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 encode#3559
4ef5301
to
378d6a1
Compare
Not sure what the best way to test this is, happy to add tests if someone points the way. |
@@ -118,7 +118,10 @@ def filter_queryset(self, request, queryset, view): | |||
|
|||
def to_html(self, request, queryset, view): | |||
cls = self.get_filter_class(view, queryset) | |||
filter_instance = cls(request.query_params, queryset=queryset) | |||
if cls: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general note/nitpick can we go ahead and also make this look like the filter_query()
method on top, basically just renaming cls
for filter_class
.
@ericholscher thanks for putting this together, looks good to me. We were already doing a similar check on the |
@ericholscher also I'm wondering what does that rendered HTML looks like with no filter since both filter templates use |
An example, along with screenshots demonstrating the behavior in the |
Gonna accept this for now, given bug fix nature of the 3.3.1 release. |
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 toNone
if one does not exist.
This fixes #3559