【发布时间】:2020-08-13 07:28:13
【问题描述】:
我在模型的 Django 管理中有以下类:
class TopUpsAdmin(admin.ModelAdmin):
search_fields = ('user__email', 'user__phone_number',)
list_filter = ('status',)
目前过滤器的默认行为是
if search box in the listing page is input with test_1 which is a user name and search up the result(url will have the following parameter /?q=test_1) , if select an option in the filter then the filter results also got affected by the search box query on the URL ?q=test_1&status__exact=1)
我不希望在选择过滤器时让搜索结果过滤列表。
阅读 Django docs 仅向我提供了如何使用参数中存在的查询(来自搜索框)覆盖过滤器。
任何帮助将不胜感激
【问题讨论】:
-
如果用户想要同时进行搜索和过滤怎么办?我认为它应该保持原样,并让用户在需要时清除搜索输入。
-
@xyres 我明白,但目前我需要根据我的应用程序的要求重置过滤器选项上的搜索结果
标签: python django django-admin