You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the proposed solutions in the documentation for filtering for empty strings is adding the lookup __isempty. This can be done by registering it at the Django level (and fiddling directly with the SQL compiler) or by adding a filter which responds to the specified lookup.
Automatic generation through FilterSet.Meta.fields however fails, even if we overwrite the FilterSet.filter_for_lookup() function:
The reason is FilterSet.filter_for_field() calls the resolve_field() function on the utils module, which then uses the Django machinery to determine which part are transformers and which part is lookup, and what field type results after applying the transforms. There is no way to override the resolve_field() call without overriding the whole FilterSet.filter_for_field() function.
It would be nice if some support could be added for custom lookups. This seems a complex issue, but at least the resolve_field() call could get wrapped into a FilterSet class function which can be easily overriden in case we have to support custom lookups.
The text was updated successfully, but these errors were encountered:
One of the proposed solutions in the documentation for filtering for empty strings is adding the lookup __isempty. This can be done by registering it at the Django level (and fiddling directly with the SQL compiler) or by adding a filter which responds to the specified lookup.
Automatic generation through FilterSet.Meta.fields however fails, even if we overwrite the FilterSet.filter_for_lookup() function:
The reason is FilterSet.filter_for_field() calls the resolve_field() function on the utils module, which then uses the Django machinery to determine which part are transformers and which part is lookup, and what field type results after applying the transforms. There is no way to override the resolve_field() call without overriding the whole FilterSet.filter_for_field() function.
It would be nice if some support could be added for custom lookups. This seems a complex issue, but at least the resolve_field() call could get wrapped into a FilterSet class function which can be easily overriden in case we have to support custom lookups.
The text was updated successfully, but these errors were encountered: