Skip to content

How to customise FILTER_DEFAULTS (e.g. for FileField) #1478

Discussion options

You must be logged in to vote

Hi @clement-escolano.

There's no FileFilter.

Is there some way to make this filter_overrides globally to avoid adding it in a lot of filter sets?

You can declare a base FilterSet subclass for your project. Inheritance of internal Meta classes gets sticky, so adjusting FILTER_DEFAULTS is likely the way to go. See how the rest_framework.FilterSet class does it:

FILTER_FOR_DBFIELD_DEFAULTS = deepcopy(filterset.FILTER_FOR_DBFIELD_DEFAULTS)
FILTER_FOR_DBFIELD_DEFAULTS.update({
models.DateTimeField: {'filter_class': IsoDateTimeFilter},
models.BooleanField: {'filter_class': BooleanFilter

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@clement-escolano
Comment options

@clement-escolano
Comment options

Answer selected by clement-escolano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1477 on February 15, 2022 17:23.