问题描述
我在 page.py 上有(客户与页面的多对多关系):
def printable_customers(self):
return list(Customer.objects.filter(id__in=self.pagehascustomer_set.values_list('customer_id',flat=True)).values_list('name',flat=True))
然后我在 admin.py 上有这个
class ArticleAdmin(ModelAdmin):
model = ArticlePage
menu_label = 'Published'
list_display = ('title','go_live_at','printable_customers','owner','live',)
list_filter = ('live',)
search_fields = ('title','printable_customers')
ordering = ('go_live_at',)
现在我需要 printable_customers 在该模型管理员索引视图上进行排序和搜索。怎么做?在这个阶段,我可以看到可打印客户(例如公司 A、公司 B)列的数据,但上面没有排序按钮。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)