Replies: 9 comments
-
FilterSets can make use of inheritance, e.g.:
|
Beta Was this translation helpful? Give feedback.
-
How we will connect Person and Member relation? |
Beta Was this translation helpful? Give feedback.
-
There's nothing built in for nesting filter sets directly. But did you try a method filter (say) that instantiated the sun filter set and then used the result |
Beta Was this translation helpful? Give feedback.
-
I did it like this;
|
Beta Was this translation helpful? Give feedback.
-
this solution does not work. It gives an error when I extend the Member Filter class
|
Beta Was this translation helpful? Give feedback.
-
Why not do it in two passes...
You could pull that into the filter set to hide it from the view, but that looks pretty straightforward to my eye... 🤔 |
Beta Was this translation helpful? Give feedback.
-
I use django rest framework and i have too many views.
|
Beta Was this translation helpful? Give feedback.
-
The backend defines a filter queryset method. You can override that. |
Beta Was this translation helpful? Give feedback.
-
well, thank you very much. Since there are too many views, the method you mentioned is not suitable for me. I will try to handle it in this filter class |
Beta Was this translation helpful? Give feedback.
-
I use django-filter
I have two models named Person and Member. Person has been defined as foreign key in Member. As an example here, I added less fields, normally the PersonModel model has a lot more fields. What I want to do here is to use all the filter fields I created for person in the filter class I created for Member.
models.py
filters.py
Beta Was this translation helpful? Give feedback.
All reactions