用于多对多字段的 Django 自定义小部件 [英] Django Custom Widget For ManyToMany field

查看:19
本文介绍了用于多对多字段的 Django 自定义小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道显示 2 个选择框的小部件.一个显示模型中所有对象的列表,另一个显示已选择的对象.然后用户可以从第一个列表中选择一个对象,单击 >> 按钮将其移动到选定"列表.然后在保存表单时,所选列表中的对象将保存在 manytomany 字段中.

Does anyone know of a widget that displays 2 select boxes. One shows a list of all object in a model and the other shows the objects which have been selected. The user can then select an object from the first list, click an >> button which moves it to the 'selected' list. Then when the form is saved the objects in the selected list are saved in the manytomany field.

谢谢

推荐答案

django.contrib.admin.widgets.FilteredSelectMultiple

django.contrib.admin.widgets.FilteredSelectMultiple

这篇关于用于多对多字段的 Django 自定义小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆