Skip to content

Commit

Permalink
Merge pull request #9 from acdh-oeaw/icontains-search
Browse files Browse the repository at this point in the history
Allow contains search for Text fields
  • Loading branch information
gythaogg authored Apr 23, 2024
2 parents 2b2a3e5 + db4e3ef commit fc8ec69
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions apis_ontology/filtersets.py
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",
},
},
}

0 comments on commit fc8ec69

Please sign in to comment.