File tree Expand file tree Collapse file tree 2 files changed +1
-40
lines changed Expand file tree Collapse file tree 2 files changed +1
-40
lines changed Original file line number Diff line number Diff line change @@ -91,50 +91,13 @@ Which you could query as follows:
9191 }
9292 }
9393
94- Orderable fields
95- ----------------
96-
97- Ordering can also be specified using ``filter_order_by ``. Like
98- ``filter_fields ``, this value is also passed directly to
99- ``django-filter `` as the ``order_by `` field. For full details see the
100- `order\_ by
101- documentation <https://django-filter.readthedocs.org/en/latest/usage.html#ordering-using-order-by> `__.
102-
103- For example:
104-
105- .. code :: python
106-
107- class AnimalNode (DjangoObjectType ):
108- class Meta :
109- model = Animal
110- filter_fields = [' name' , ' genus' , ' is_domesticated' ]
111- # Either a tuple/list of fields upon which ordering is allowed, or
112- # True to allow filtering on all fields specified in filter_fields
113- filter_order_by = True
114- interfaces = (relay.Node, )
115-
116- You can then control the ordering via the ``orderBy `` argument:
117-
118- .. code ::
119-
120- query {
121- allAnimals(orderBy: "name") {
122- edges {
123- node {
124- id,
125- name
126- }
127- }
128- }
129- }
130-
13194 Custom Filtersets
13295-----------------
13396
13497By default Graphene provides easy access to the most commonly used
13598features of ``django-filter ``. This is done by transparently creating a
13699``django_filters.FilterSet `` class for you and passing in the values for
137- ``filter_fields `` and `` filter_order_by `` .
100+ ``filter_fields ``.
138101
139102However, you may find this to be insufficient. In these cases you can
140103create your own ``Filterset `` as follows:
Original file line number Diff line number Diff line change @@ -98,7 +98,6 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
9898 class Meta :
9999 model = Category
100100 filter_fields = [' name' , ' ingredients' ]
101- filter_order_by = [' name' ]
102101 interfaces = (relay.Node, )
103102
104103
@@ -112,7 +111,6 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
112111 ' category' : [' exact' ],
113112 ' category__name' : [' exact' ],
114113 }
115- filter_order_by = [' name' , ' category__name' ]
116114 interfaces = (relay.Node, )
117115
118116
You can’t perform that action at this time.
0 commit comments