Skip to content
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

fix #78: Add CallableFilter.is_field and modify CallableFilter.lookups #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fix #78: Add CallableFilter.is_field and modify CallableFilter.lookups #79

wants to merge 1 commit into from

Conversation

eralumin
Copy link

@eralumin eralumin commented Feb 6, 2019

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