简体   繁体   English

如何在 Django 中创建这样的表单,这种表单的名称是什么?

[英]How can I create such a form in Django and what is the name of this type of form?

I'm trying to create a form in Django, part of which is a long list of strings (component names).我正在尝试在 Django 中创建一个表单,其中一部分是一长串字符串(组件名称)。 The user using the form should be able to select one or more components, move them from the left list to the right, and submit these names (in the right list) with the form.使用表单的用户应该能够选择一个或多个组件,将它们从左侧列表移到右侧,并与表单一起提交这些名称(在右侧列表中)。

This is also used in the Django administration interface as you can see on my screenshot.正如您在我的屏幕截图中看到的那样,这也用于 Django 管理界面。

Django admin interface Django 管理界面

Unfortunately, I have no idea what this type of form is called.不幸的是,我不知道这种形式的名称是什么。 Therefore it is difficult to find a solution on google if you don't have the right search parameters ...;)因此,如果您没有正确的搜索参数,则很难在 google 上找到解决方案...;)

If someone even had a snippet of code to create this form, it would be even better.如果有人甚至有一段代码来创建这个表单,那就更好了。

I just found the answer myself after "adjusting" the search parameters in Google.我只是在“调整”Google 中的搜索参数后自己找到了答案。 Before, none of the results matched my question, now I had tried a query "Django forms move several elements from left to right" just for fun.之前,没有任何结果符合我的问题,现在我尝试了一个查询“Django 表单从左到右移动多个元素”只是为了好玩。 ;) One of the possible solutions was this question here on stackoverflow: " Multiple left to right selection field ", which then also contained the answer to my question. ;) 可能的解决方案之一是 stackoverflow 上的这个问题:“ 多个从左到右的选择字段”,其中还包含我的问题的答案。

If someone else is looking for this type of form, the element is called "FilteredSelectMultiple-Widget with filter_horizontal on a ManyToManyField".如果其他人正在寻找这种类型的表单,则该元素称为“FilteredSelectMultiple-Widget with filter_horizo​​ntal on a ManyToManyField”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM