-
Notifications
You must be signed in to change notification settings - Fork 755
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
Possibility to embed a filterset in another #587
Comments
https://django-filter.readthedocs.io/en/develop/ref/filters.html#name This should give you what you need, yes? |
@carltongibson unfortunately not. I'm already using double-underscore. The problem is suppose that |
Hmmm. OK. The short answer is, there's nothing built in. But you should be able to do something with a Mixin or such. |
I see, so can we consider this issue as a feature request? Something like |
Hi @sassanh - have you seen django-rest-framework-filters? Even if you're not using DRF, the |
Side note - I currently maintain the package and am in the process of refactoring how related filtersets work. I'd recommend reading through the open issues to see if the package works for you in its current state. Notably, there are issues 99 and 100 and the filtering behavior when spanning multi-valued relationships. The package is changing from the join syntax to a subquery approach, which exhibits more correct behavior. |
@rpkilby oh great, I see it has many other nice features too. I can postpone this part of project till version 1.0 is out. Is there any expected time for version 1.0? |
No timeline, although I now have some spare time on my hands that can be put towards the project. |
The other approach is to construct the You have a base filter set and then add the additional fields calling
In your case it sounds like you have a lot of repetition so something dynamic may suit but in general I advise a little bit more typing at the declaration stage to save (maintenance) pain later. |
thanks @carltongibson in case django-rest-framework-filters wasn't ready at the time when I'm going to implement filters I can use this backup plan. |
Suppose that we have 2 models for example, Student and School. We have a filterset for student, for example we can query by
birthdate__gt
for example now suppose that we wanna have exact same filters for school but prefixed withstudent__
so that we can query bystudent__birthdate__gt
. Is it possible to somehow embed a filterset in another and make it apply to a foreignkey or manytomanyfield?The text was updated successfully, but these errors were encountered: