问题描述
我想问一下是否有任何字段(如下面所附的字段)在Django中作为单个对象可用.如果否,那么我们如何生成将所选项目移到右侧的功能.
I would like to ask whether there is any field, like the one attached below, available in Django as a single object. If no, then how can we generate such a functionality of moving selected items to the right hand side.
请指导,我将非常感谢.
Please guide, I shall be extremly thankful.
推荐答案
您可以使用Django的 FilteredSelectMultiple
小部件,如使用 filter_horizontal
在ManyToManyField
上:
You could make use of Django's FilteredSelectMultiple
widget, as seen in the django-admin when you use filter_horizontal
on a ManyToManyField
:
以下是使用您自己的表单自己进行操作的示例: http://djangosnippets.org/snippets/2466/
Here's an example of doing it yourself with your own form: http://djangosnippets.org/snippets/2466/
这篇关于多个从左到右的选择字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!