Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModelFilterSet._build_filter_from_field: set default_lookups #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions url_filter/filtersets/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,18 @@ def _build_filter(self, name, state):

def _build_filter_from_field(self, name, field):
"""
Build :class:`.Filter` for a standard Django model field.
Build :class:`.Filter` for a standard Django model field. Retrieve
default field lookups if no lookups are specified by the user.
"""
filter_extra_kwargs = self._get_filter_extra_kwargs(name)

if not filter_extra_kwargs.get("lookups", None):
filter_extra_kwargs["lookups"] = tuple(field.get_lookups().keys())

return Filter(
form_field=self._get_form_field_for_field(field),
is_default=field.primary_key,
**self._get_filter_extra_kwargs(name)
**filter_extra_kwargs
)

def _build_filterset_from_related_field(self, name, field):
Expand Down