-
Notifications
You must be signed in to change notification settings - Fork 61
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
Adding FlexFieldsFilterBackend immediately breaks the app #46
Comments
Yeah seeing this too, but I get:
looks like a circular import also |
As a workaround (I also posted this at #59 which appears to be a duplicate) you can set the filter backend at the view: import rest_flex_fields.filter_backends as flex_filters
from rest_framework import viewsets
class ModelViewSet(viewsets.ModelViewSet):
filter_backends = viewsets.ModelViewSet.filter_backends + [
flex_filters.FlexFieldsFilterBackend,
] |
Starting from @wolph idea, I have created a mixin to replace the "FlexFieldsMixin" that includes the FilterBackend and also respects the user's settings. I'll leave the code here just in case there was anyone interested. from rest_flex_fields.filter_backends import FlexFieldsFilterBackend
from rest_flex_fields.views import FlexFieldsMixin
from rest_framework.settings import api_settings
class FlexFieldsOptimizedMixin(FlexFieldsMixin):
filter_backends = [FlexFieldsFilterBackend] + api_settings.DEFAULT_FILTER_BACKENDS from rest_framework import viewsets
from .mixins import FlexFieldsOptimizedMixin
class ModelViewSet(FlexFieldsOptimizedMixin, viewsets.ModelViewSet):
... |
I am utilizing drf-flex-fields heavily and everything works fine until the moment i add:
It crashes the app with the following traceback:
Adding the backend directly to the view works fine.
The text was updated successfully, but these errors were encountered: