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:
115115 class AnimalFilter (django_filters .FilterSet ):
116116 # Do case-insensitive lookups on 'name'
117117 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' )))
118123
119124 class Meta :
120125 model = Animal
@@ -127,6 +132,23 @@ create your own ``Filterset`` as follows:
127132 all_animals = DjangoFilterConnectionField(AnimalNode,
128133 filterset_class = AnimalFilter)
129134
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+
130152 The context argument is passed on as the `request argument <http://django-filter.readthedocs.io/en/master/guide/usage.html#request-based-filtering >`__
131153in a ``django_filters.FilterSet `` instance. You can use this to customize your
132154filters to be context-dependent. We could modify the ``AnimalFilter `` above to
You can’t perform that action at this time.
0 commit comments