Fixes #7089 - Adds Q filter to ContentTypeFilterSet

This commit is contained in:
Daniel Sheppard 2021-08-31 11:31:40 -05:00
parent 7b7b01a26b
commit 86da6c6c14
2 changed files with 13 additions and 0 deletions

View File

@ -11,6 +11,7 @@
* [#7082](https://github.com/netbox-community/netbox/issues/7082) - Avoid exception when referencing invalid content type in table
* [#7083](https://github.com/netbox-community/netbox/issues/7083) - Correct labeling for VM memory attribute
* [#7084](https://github.com/netbox-community/netbox/issues/7084) - Fix KeyError exception when editing access VLAN on an interface
* [#7089](https://github.com/netbox-community/netbox/issues/7089) - Fix ContentTypeFilterSet not filtering on q filter
* [#7096](https://github.com/netbox-community/netbox/issues/7096) - Home links should honor `BASE_PATH` configuration
---

View File

@ -367,6 +367,18 @@ class JobResultFilterSet(BaseFilterSet):
#
class ContentTypeFilterSet(django_filters.FilterSet):
q = django_filters.CharFilter(
method='search',
label='Search',
)
def search(self, queryset, name, value):
if not value.strip():
return queryset
return queryset.filter(
Q(app_label__icontains=value) |
Q(model__icontains=value)
)
class Meta:
model = ContentType