File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,27 @@ This is a map of model fields to filter classes with options::
148
148
}
149
149
150
150
151
+
152
+ A possible usecase would be creating a custom filter to be able to filter on ``FileFields``
153
+ (``FileField`` filtering is hard to define in a generalised way, which is why there is no ``FileFilter``).
154
+
155
+ This example shows an override used to filter on a ``FileField``::
156
+
157
+ class Questionnaire(models.Model):
158
+ file = models.FileField(upload_to=questionnaire_path)
159
+
160
+ class QuestionnaireFilter(FilterSet):
161
+ class Meta:
162
+ model = Questionnaire
163
+ fields = ['file']
164
+ filter_overrides = {
165
+ models.FileField: {
166
+ 'filter_class': CharFilter,
167
+ 'extra': lambda f: {'lookup_expr': 'exact'},
168
+ },
169
+ }
170
+
171
+
151
172
.. _unknown_field_behavior:
152
173
153
174
Handling unknown fields with ``unknown_field_behavior``
You can’t perform that action at this time.
0 commit comments