Skip to content

Commit 0cbb91e

Browse files
author
Ryan P Kilby
committed
Add ALL_LOOKUPS to filters
This is just a reference to django.db.models.sql.constants.QUERY_TERMS, which is a list of all valid lookups.
1 parent 68efb74 commit 0cbb91e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ and also filter on the default lookup (``exact``), as usual::
127127

128128
/api/page/?title=The%20Park
129129

130+
Additionally, you may use ``ALL_LOOKUPS`` with dictionary style declarations.
131+
132+
.. code-block:: python
133+
134+
import rest_framework_filters as filters
135+
136+
class PageFilter(filters.FilterSet):
137+
...
138+
139+
class Meta:
140+
fields = {
141+
'title': filters.ALL_LOOKUPS,
142+
}
143+
144+
130145
Combining RelatedFilter and AllLookupsFilter
131146
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
132147

rest_framework_filters/filters.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
import django
88
from django_filters.filters import *
9+
from django_filters.filters import LOOKUP_TYPES
910

1011
from . import fields
1112

13+
ALL_LOOKUPS = LOOKUP_TYPES
14+
1215

1316
def _import_class(path):
1417
module_path, class_name = path.rsplit('.', 1)

0 commit comments

Comments
 (0)