我有这段代码,但老老实实地选择性地工作:
def get_search_results(self, request, queryset, search_term):
queryset, use_distinct = super(Name_of_adminclass, self).get_search_results(
request, queryset, search_term)
search_words = search_term.split(',')
if search_words:
q_objects = [Q(**{field + '__iexact': word})
for field in self.search_fields
for word in search_words]
queryset |= self.model.objects.filter(reduce(or_, q_objects))
return queryset, use_distinct
同样出于任何原因,它似乎禁用过滤器以使它们不起作用,用逗号搜索确切的术语有时会起作用,任何人都可以提供帮助吗?