我在django管理界面中有一个自定义过滤器
class ClipExcludeRightsFilter(ListFilter):
title = 'rights'
parameter_name = 'exclude_rights'
template = 'admin_mod/filters/exclude_rights.html'
def lookups(self, request, model_admin):
result = (
('avod', 'avod'),
('svod', 'svod'),
('est', 'est'),
('tvod', 'tvod')
)
return result
def queryset(self, request, queryset):
if self.value():
urls_owner = ClipRestriction.objects.exclude(vod_system=self.value()).values_list('clip_id', flat=True)
return queryset.filter(
pk__in=urls_owner
)在接口中,它返回list ( select ),我只能选择一个属性。但我需要实现多重选择。我发现,这个默认模板是template/admin/filter.html
{% load i18n %}
<h3>{% blocktrans with filter_title=title|capfirst %} By {{ filter_title }} {% endblocktrans %}</h3>
<select class="combobox">
{% for choice in choices %}
<option{% if choice.selected %} selected{% endif %} value="{{ choice.query_string|iriencode }}" >{{ choice.display }}</option>
{% endfor %}
</select>也许我需要写我自己的模板,但不知道如何(我需要立即过滤选定的选项)。
发布于 2016-12-08 10:03:56
我刚刚选择了所有选项:使用jquery进行选择,然后将其作为参数传递到我的url中。
https://stackoverflow.com/questions/40977358
复制相似问题