-
Notifications
You must be signed in to change notification settings - Fork 130
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
Rework related filtering #199
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rpkilby
force-pushed
the
rework-related-filtering-v2
branch
2 times, most recently
from
October 26, 2017 13:30
f651e3d
to
2a1bb6b
Compare
rpkilby
force-pushed
the
rework-related-filtering-v2
branch
3 times, most recently
from
December 30, 2017 17:54
9471a95
to
a40e3d4
Compare
rpkilby
force-pushed
the
rework-related-filtering-v2
branch
9 times, most recently
from
January 15, 2018 13:48
fbbad5b
to
8741f69
Compare
rpkilby
force-pushed
the
rework-related-filtering-v2
branch
2 times, most recently
from
July 14, 2018 05:18
f57073e
to
6fc6ee1
Compare
Alright, I'm largely satisfied with this PR. I need to carefully review the code and ensure the tests adequately cover the new behavior, but otherwise, this PR accomplishes what I want it to. In addition to the general improvements to filtering across relationships, it's worth noting that this PR enables annotation support for related filtersets, as well as form rendering for first-level relationships. |
rpkilby
force-pushed
the
rework-related-filtering-v2
branch
9 times, most recently
from
July 15, 2018 03:35
976b16d
to
f7a4884
Compare
rpkilby
force-pushed
the
rework-related-filtering-v2
branch
12 times, most recently
from
July 15, 2018 19:18
c677ddb
to
87cf88f
Compare
- Form subclass parses its parameters relative to its relationship. - Form subclass collects and nests errors from its related filtersets.
rpkilby
force-pushed
the
rework-related-filtering-v2
branch
from
July 15, 2018 19:50
87cf88f
to
e8c5976
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative implementation to #197. This also needs further testing, but in general I'm happier with it.
The major difference is how data is passed between filtersets. In the current implementation (and #197), related filtersets are provided with a transformed data dictionary where their relationship name has been stripped from the data keys. The downside to #197 is that it's not possible to render related filterset forms.
In contrast, this approach passes the same incoming data to its related filtersets, untransformed. As a result, users should have a way to render related filterset forms with no conflict.
Overall, here is what this PR would enable:
field_name
).Changes:
FilterSet.relationship
, which allows the filterset to parse it's params across relationships.This is compatible withIt turns out, form prefixes aren't directly compatible, as the subsetting happens before parent initialization/filter deepcopy'ing, and prefix/relationship detection only occurs after. This could be supported, but it doesn't seem worth the trouble. i.e., we don't need prefixes to support rendering related filtersets.form_prefix
, although that's not usually relevant with API filtersets.FilterSet.get_related_filtersets()
method and it's correspondingFilterSet.related_filtersets
attribute. The latter is simply the cached result of the former. This method constructs a dict of related filtersets, keyed by their relationship name.FilterSet.filter_related_filtersets()
method, which is a hook for defining the behavior of how related filtersets are filtered.TODO:
FilterSet.get_related_filtersets()
TestImplicit through existing testsFilterSet.filter_related_filtersets()