Filtering in my browsable api leaks information of my customers, therefore I would like to disable it, like I have done with the forms in the browsable API.
Does anyone know how to do this?
I'm new to the code, could you post some example code?
Anyone looking for how to do this today, you can override the to_html
method and register your custom filter backend instead of the DRF one.
``` python.py
class DisabledHTMLFilterBackend(filters.DjangoFilterBackend):
def to_html(self, request, queryset, view):
return ""
```
See also: issue #3905
Thank you!
This is how it looks now for me (note the latter two are commented):
'DEFAULT_FILTER_BACKENDS': (
'framework.api.filters.DisabledHTMLFilterBackend',
'framework.api.filters.DjangoObjectPermissionsFilter',
#'rest_framework_filters.backends.DjangoFilterBackend', # not used!
#'rest_framework.filters.DjangoFilterBackend',
Most helpful comment
Anyone looking for how to do this today, you can override the
to_html
method and register your custom filter backend instead of the DRF one.``` python.py
class DisabledHTMLFilterBackend(filters.DjangoFilterBackend):
```
See also: issue #3905