我需要添加搜索或过滤内联数据的功能(admin.TabularInline)
class CommandsInline(admin.TabularInline):
model = Command
readonly_fields = ('id', 'owner_phone_version', 'operation', 'command', 'options', 'created')
exclude = ('owner', 'token', 'owner_phone', 'parameter', 'value')
extra = 0
max_num = 0
ordering = ('-created',)
def command(self, instance):
return format_html(mark_safe("<b>%s</b>=%s" % (instance.parameter, instance.value)))
def owner_phone_version(self, instance):
return format_html(mark_safe("<b>%s</b>. <em>%s</em>" % (instance.owner_phone.id, instance.owner_phone.version)))
我尝试将list_search和list_filter添加到定义中,但它在django admin中没有任何效果。
有什么建议吗?