mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-07 15:10:35 +03:00
Merge pull request #466 from ramonsaraiva/pin-filtering-docs
Pin django-filter in filtering docs
This commit is contained in:
commit
96789b291f
|
@ -2,9 +2,9 @@ Filtering
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Graphene integrates with
|
Graphene integrates with
|
||||||
`django-filter <https://django-filter.readthedocs.org>`__ to provide
|
`django-filter <https://django-filter.readthedocs.io/en/1.1.0/>`__ (< 2.0.0) to provide
|
||||||
filtering of results. See the `usage
|
filtering of results. See the `usage
|
||||||
documentation <https://django-filter.readthedocs.io/en/latest/guide/usage.html#the-filter>`__
|
documentation <https://django-filter.readthedocs.io/en/1.1.0/guide/usage.html#the-filter>`__
|
||||||
for details on the format for ``filter_fields``.
|
for details on the format for ``filter_fields``.
|
||||||
|
|
||||||
This filtering is automatically available when implementing a ``relay.Node``.
|
This filtering is automatically available when implementing a ``relay.Node``.
|
||||||
|
@ -15,7 +15,7 @@ You will need to install it manually, which can be done as follows:
|
||||||
.. code:: bash
|
.. code:: bash
|
||||||
|
|
||||||
# You'll need to django-filter
|
# You'll need to django-filter
|
||||||
pip install django-filter
|
pip install django-filter==1.1.0
|
||||||
|
|
||||||
Note: The techniques below are demoed in the `cookbook example
|
Note: The techniques below are demoed in the `cookbook example
|
||||||
app <https://github.com/graphql-python/graphene-django/tree/master/examples/cookbook>`__.
|
app <https://github.com/graphql-python/graphene-django/tree/master/examples/cookbook>`__.
|
||||||
|
@ -26,7 +26,7 @@ Filterable fields
|
||||||
The ``filter_fields`` parameter is used to specify the fields which can
|
The ``filter_fields`` parameter is used to specify the fields which can
|
||||||
be filtered upon. The value specified here is passed directly to
|
be filtered upon. The value specified here is passed directly to
|
||||||
``django-filter``, so see the `filtering
|
``django-filter``, so see the `filtering
|
||||||
documentation <https://django-filter.readthedocs.io/en/latest/guide/usage.html#the-filter>`__
|
documentation <https://django-filter.readthedocs.io/en/1.1.0/guide/usage.html#the-filter>`__
|
||||||
for full details on the range of options available.
|
for full details on the range of options available.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
@ -127,7 +127,7 @@ create your own ``Filterset`` as follows:
|
||||||
all_animals = DjangoFilterConnectionField(AnimalNode,
|
all_animals = DjangoFilterConnectionField(AnimalNode,
|
||||||
filterset_class=AnimalFilter)
|
filterset_class=AnimalFilter)
|
||||||
|
|
||||||
The context argument is passed on as the `request argument <http://django-filter.readthedocs.io/en/latest/guide/usage.html#request-based-filtering>`__
|
The context argument is passed on as the `request argument <http://django-filter.readthedocs.io/en/1.1.0/guide/usage.html#request-based-filtering>`__
|
||||||
in a ``django_filters.FilterSet`` instance. You can use this to customize your
|
in a ``django_filters.FilterSet`` instance. You can use this to customize your
|
||||||
filters to be context-dependent. We could modify the ``AnimalFilter`` above to
|
filters to be context-dependent. We could modify the ``AnimalFilter`` above to
|
||||||
pre-filter animals owned by the authenticated user (set in ``context.user``).
|
pre-filter animals owned by the authenticated user (set in ``context.user``).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user