-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from acdh-oeaw/icontains-search
Allow contains search for Text fields
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from apis_core.apis_entities.filtersets import AbstractEntityFilterSet | ||
from django.db import models | ||
import django_filters | ||
|
||
|
||
class LegacyStuffMixinFilterSet(AbstractEntityFilterSet): | ||
class Meta(AbstractEntityFilterSet.Meta): | ||
filter_overrides = { | ||
models.CharField: { | ||
"filter_class": django_filters.CharFilter, | ||
"extra": lambda f: { | ||
"lookup_expr": "icontains", | ||
}, | ||
}, | ||
models.TextField: { | ||
"filter_class": django_filters.CharFilter, | ||
"extra": lambda f: { | ||
"lookup_expr": "icontains", | ||
}, | ||
}, | ||
} | ||
|
||
|
||
class TibScholEntityMixinFilterSet(AbstractEntityFilterSet): | ||
class Meta(AbstractEntityFilterSet.Meta): | ||
filter_overrides = { | ||
models.TextField: { | ||
"filter_class": django_filters.CharFilter, | ||
"extra": lambda f: { | ||
"lookup_expr": "icontains", | ||
}, | ||
}, | ||
} | ||
|
||
|
||
class InstanceMixinFilterSet(AbstractEntityFilterSet): | ||
class Meta(AbstractEntityFilterSet.Meta): | ||
filter_overrides = { | ||
models.TextField: { | ||
"filter_class": django_filters.CharFilter, | ||
"extra": lambda f: { | ||
"lookup_expr": "icontains", | ||
}, | ||
}, | ||
} |