File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ create your own ``Filterset`` as follows:
115
115
class AnimalFilter (django_filters .FilterSet ):
116
116
# Do case-insensitive lookups on 'name'
117
117
name = django_filters.CharFilter(lookup_expr = [' iexact' ])
118
+ # Allow multiple genera to be selected at once
119
+ genera = django_filters.MultipleChoiceFilter(field_name = ' genus' ,
120
+ choices = ((' Canis' , ' Canis' ),
121
+ (' Panthera' , ' Panthera' ),
122
+ (' Seahorse' , ' Seahorse' )))
118
123
119
124
class Meta :
120
125
model = Animal
@@ -127,6 +132,23 @@ create your own ``Filterset`` as follows:
127
132
all_animals = DjangoFilterConnectionField(AnimalNode,
128
133
filterset_class = AnimalFilter)
129
134
135
+ If you were interested in selecting all dogs and cats, you might query as follows:
136
+
137
+ .. code ::
138
+
139
+ query {
140
+ allAnimals(genera: ["Canis", "Panthera"]) {
141
+ edges {
142
+ node {
143
+ id,
144
+ name
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+
151
+
130
152
The context argument is passed on as the `request argument <http://django-filter.readthedocs.io/en/master/guide/usage.html#request-based-filtering >`__
131
153
in a ``django_filters.FilterSet `` instance. You can use this to customize your
132
154
filters to be context-dependent. We could modify the ``AnimalFilter `` above to
You can’t perform that action at this time.
0 commit comments