Django 管理员 +过滤器水平?
我添加了 水平过滤器
filter_horizontal = ('blocked_email_notifications',)
到我的 ModelAdmin
,但它仍然将其呈现为多选小部件,而不是漂亮的 javascript 增强版本。怎么会?我还需要添加其他东西吗?
用户模型将其定义为
blocked_email_notifications = ManyToManyField('EmailTemplate', blank=True)
表单将其定义为
blocked_email_notifications = ModelMultipleChoiceField(queryset=EmailTemplate.objects.order_by('key'), required=False)
I've added filter horizontal
filter_horizontal = ('blocked_email_notifications',)
To my ModelAdmin
, but it's still rendering it as a multiple select widget, rather than the nifty javascript enhanced version. How come? Do I need to add something else?
The user model has it defined as
blocked_email_notifications = ManyToManyField('EmailTemplate', blank=True)
And the form has it defined as
blocked_email_notifications = ModelMultipleChoiceField(queryset=EmailTemplate.objects.order_by('key'), required=False)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在表单中定义字段,则需要包含小部件:
is_stacked
:False
:列表并排呈现True
:列表呈现为一个在另一个之下If you define the field in the form you need to include the widget:
is_stacked
:False
: the lists are rendered side by sideTrue
: the lists are rendered one underneath the other