简体   繁体   English

在Django中使用“其他”选项自动完成选择列表

[英]Autocompleting list of choices with 'other' option in django

I have a django form element (Musical Instrument) where I'd like to autocomplete from a list of choices (eg ['Piano', 'Guitar', 'Drums', 'Bass']), but allow the user to enter something else if it isn't in the list. 我有一个django表单元素(乐器),在这里我想从选项列表(例如['Piano','Guitar','Drums','Bass'])中自动完成,但允许用户输入一些内容否则,如果不在列表中。

I'm currently using autocomplete-light, but can swap this for something else if need be. 我目前使用的是自动补光功能,但如果需要可以将其替换为其他功能。

Any ideas? 有任何想法吗?

It would be helpful to see the model and form. 看到模型和表格会很有帮助。

If you are using a simple charfield in your model and set the choices in the automcomplete class, you should be able to input arbitrary values. 如果在模型中使用简单的charfield并在automcomplete类中设置选择,则应该能够输入任意值。

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

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