Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Contributors
* Ryan O’Hara - https://github.com/ryan-copperleaf
* webrunners - https://github.com/webrunners
* Simone Pellizzari - https://github.com/simone6021
* Jonathon Farzanfar - https://github.com/pctSW1
12 changes: 12 additions & 0 deletions tests/filtersets/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ class Meta(object):
'id', 'name', 'a', 'content_type', 'object_id',
}

def test_get_filters_using_all(self):
class ModelBFilterSet(ModelFilterSet):
class Meta(object):
model = ModelB
fields = '__all__'

filters = ModelBFilterSet().get_filters()

assert set(filters.keys()) == {
'id', 'name', 'a', 'content_type', 'object_id',
}

def test_get_form_field_for_field(self):
fs = ModelFilterSet()

Expand Down
5 changes: 3 additions & 2 deletions url_filter/filtersets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
'ModelFilterSetOptions',
]


LOOKUP_RE = re.compile(
r'^(?:[^\d\W]\w*)(?:{}?[^\d\W]\w*)*(?:!)?$'
r''.format(LOOKUP_SEP), re.IGNORECASE
Expand Down Expand Up @@ -54,6 +53,7 @@ class FilterSetOptions(object):
Base class for handling options passed to :class:`.FilterSet`
via ``Meta`` attribute.
"""

def __init__(self, options=None):
pass

Expand Down Expand Up @@ -436,6 +436,7 @@ class ModelFilterSetOptions(FilterSetOptions):
extra_kwargs : dict, optional
Additional kwargs to be given to auto-generated individual filters
"""

def __init__(self, options=None):
super(ModelFilterSetOptions, self).__init__(options)
self.model = getattr(options, 'model', None)
Expand Down Expand Up @@ -467,7 +468,7 @@ def get_filters(self):
''.format(name=self.__class__.__name__)
)

if self.Meta.fields is None:
if self.Meta.fields in [None, '__all__']:
self.Meta.fields = self._get_model_field_names()

state = self._build_state()
Expand Down