Skip to content

Commit

Permalink
Remove order_by in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Nov 23, 2016
1 parent 9216772 commit 9d35b76
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
39 changes: 1 addition & 38 deletions docs/filtering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,50 +91,13 @@ Which you could query as follows:
}
}
Orderable fields
----------------

Ordering can also be specified using ``filter_order_by``. Like
``filter_fields``, this value is also passed directly to
``django-filter`` as the ``order_by`` field. For full details see the
`order\_by
documentation <https://django-filter.readthedocs.org/en/latest/usage.html#ordering-using-order-by>`__.

For example:

.. code:: python
class AnimalNode(DjangoObjectType):
class Meta:
model = Animal
filter_fields = ['name', 'genus', 'is_domesticated']
# Either a tuple/list of fields upon which ordering is allowed, or
# True to allow filtering on all fields specified in filter_fields
filter_order_by = True
interfaces = (relay.Node, )
You can then control the ordering via the ``orderBy`` argument:

.. code::
query {
allAnimals(orderBy: "name") {
edges {
node {
id,
name
}
}
}
}
Custom Filtersets
-----------------

By default Graphene provides easy access to the most commonly used
features of ``django-filter``. This is done by transparently creating a
``django_filters.FilterSet`` class for you and passing in the values for
``filter_fields`` and ``filter_order_by``.
``filter_fields``.

However, you may find this to be insufficient. In these cases you can
create your own ``Filterset`` as follows:
Expand Down
2 changes: 0 additions & 2 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
class Meta:
model = Category
filter_fields = ['name', 'ingredients']
filter_order_by = ['name']
interfaces = (relay.Node, )
Expand All @@ -112,7 +111,6 @@ Create ``cookbook/ingredients/schema.py`` and type the following:
'category': ['exact'],
'category__name': ['exact'],
}
filter_order_by = ['name', 'category__name']
interfaces = (relay.Node, )
Expand Down

0 comments on commit 9d35b76

Please sign in to comment.