Skip to content

Commit

Permalink
Add LookupChoiceFilter docs and migration note
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan P Kilby committed May 21, 2018
1 parent 8ba64ec commit 26dbb81
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/guide/migration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ a fully forards-compatible migration release. Please review the below list of
changes and update your code accordingly.


``Filter.lookup_expr`` list form removed (`#851`__)
-------------------------------------------
__ https://github.com/carltongibson/django-filter/pull/851

The ``Filter.lookup_expr`` argument no longer accepts ``None`` or a list of
expressions. Use the :ref:`LookupChoiceFilter <lookup-choice-filter>` instead.


FilterSet ``Meta.together`` option removed (`#791`__)
-----------------------------------------------------
__ https://github.com/carltongibson/django-filter/pull/791
Expand Down
25 changes: 25 additions & 0 deletions docs/ref/filters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,31 @@ database. So if in the DB for the given field you have values of 5, 7, and 9
each of those is present as an option. This is similar to the default behavior
of the admin.

.. _lookup-choice-filter:

``LookupChoiceFilter``
~~~~~~~~~~~~~~~~~~~~~~

A combined filter that allows users to select the lookup expression from a dropdown.

* ``lookup_choices`` is an optional argument that accepts multiple input
formats, and is ultimately normlized as the choices used in the lookup
dropdown. See ``.get_lookup_choices()`` for more information.

* ``field_class`` is an optional argument that allows you to set the inner
form field class used to validate the value. Default: ``forms.CharField``

ex::

price = django_filters.LookupChoiceFilter(
field_class=forms.DecimalField,
lookup_choices=[
('exact', 'Equals'),
('gt', 'Greater than'),
('lt', 'Less than'),
]
)

.. _base-in-filter:

``BaseInFilter``
Expand Down

0 comments on commit 26dbb81

Please sign in to comment.