如何在django中添加select all?

时间:2017-11-26 07:43:15

标签: jquery django django-forms

我希望有一个像https://www.jquery-az.com/boots/demo.php?ex=63.0_9

这样的表单

我如何在django中制作这个表格?

谢谢

这是我使用django-selectable的形式:

from django import forms

from rapidsms.router import send

from selectable.forms import AutoCompleteSelectMultipleField

from .lookups import ConnectionLookup



class MessageForm(forms.Form):
  message = forms.CharField(widget=forms.Textarea)
  connections = AutoCompleteSelectMultipleField(
     lookup_class=ConnectionLookup)


  def __init__(self, *args, **kwargs):
    super(MessageForm, self).__init__(*args, **kwargs)
    self.fields['connections'].widget.attrs['placeholder'] = 'Add a Recipient'
    self.fields['message'].widget.attrs['placeholder'] = 'Message'

  def send(self):
    message = self.cleaned_data['message']
    connections = self.cleaned_data['connections']
    return send(message, connections)

0 个答案:

没有答案