-
Notifications
You must be signed in to change notification settings - Fork 758
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
DRF FilterBackend & FilterSet #429
Conversation
43ef98d
to
af01d78
Compare
@rpkilby Good work! Give me a couple of days to look at this. Awesome |
models.DurationField: { | ||
'filter_class': DurationFilter | ||
}, | ||
models.AutoField: {'filter_class': NumberFilter}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why the formatting was changed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to improve readability. It's definitely preference, but the compacted version is easier for me to scan than the expanded version.
de40bd8
to
da2b291
Compare
- Make FILTER_DEFAULTS a class attr. This will allow the DRF FilterSet to easily override the defaults, without relying on filter_overrides. - Move filter_overrides to the meta options, provide deprecation notice.
What's your timeline on merging #476 - are you trying to get that done this weekend? |
@rpkilby Yes. I'd like to get it in — even if it needs a bit of follow-up work. |
Sounds good - I'll try to take a look tomorrow night. If I don't have time, can always submit a PR later. |
It's more like - I'll either open my laptop or I won't. Road trip in the morning, tubing in the afternoon, but otherwise my evening should be clear 😄 |
@rpkilby OK. Cool. (Remember it's Open Source and doesn't own you! :-) ) |
Hey @carltongibson I reviewed the rebased version and decided to do some additional rebasing. I don't think I can submit a PR to the other branch because of the rebasing - do you want to reopen this PR instead? Changes:
|
docs added (preview here). |
This is an attempt at #275.
Notes:
FILTER_DEFAULTS
a FilterSet class attribute. This allows the DRF FilterSet to modify the defaults without relying onfilter_overrides
. Usingfilter_overrides
would complicate the API, as subclasses would have to copy the changes in addition to making their own.filter_overrides
a meta option, providing a deprecation notice for the class attribute. This seems more correct? Behavior modifying options should exist in the class meta, not on the class itself (which should just be the declarative filters). Either way, can revert this and raise in a separate issue - I'd argue thatstrict
andorder_by_field
should also be moved to meta.django_filters.rest_framework
does not have a conditional dependency on DRF (asrest_framework.filters
had on django-filter). It doesn't seem necessary, as you won't be loading the rest_framework sub-package unless DRF is installed.FilterBackend
and tests are almost entirely a carbon copy of what exists on the current DRF master branch.Questions:
crispy_forms
conditional dependency be kept?TODO: