Skip to content

Conversation

vesperrin
Copy link

No description provided.

Copy link
Owner

@miki725 miki725 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the callable filter backs a model field, unless explicitly implemented it cannot filter any of the standard lookups like exact. Therefore it should not return any of the standard lookups as being supported. Only custom implemented lookups should be allowed unless Im forgetting something about the implementation details.

Also the filterset should be backend agnostic to allow to use other filter backends such as sqlalchemy. I like the idea of is_field however to implement it in generic way will require adding more hooks to a backend.

def is_field(self):
"""Return True if the attribute is instance of Field else return False.
"""
model = self.root.queryset.model
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root queryset is the top-level queryset but since filtersets can be nested model relations need to be followed to get the child model to check if it is a field. at this time there is no generic way of getting the child model which gets more complicated with other backends

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants