当前位置: 首页>>代码示例>>Python>>正文


Python forms.SelectMultiple方法代码示例

本文整理汇总了Python中django.forms.SelectMultiple方法的典型用法代码示例。如果您正苦于以下问题:Python forms.SelectMultiple方法的具体用法?Python forms.SelectMultiple怎么用?Python forms.SelectMultiple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.forms的用法示例。


在下文中一共展示了forms.SelectMultiple方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import SelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['document_type'] = forms.MultipleChoiceField(
            choices=[(t, t) for t in Document.objects
                .order_by().values_list('document_type', flat=True).distinct()],
            widget=forms.SelectMultiple(attrs={'class': 'chosen'}),
            required=False)
        self.fields = OrderedDict((k, self.fields[k]) for k in ['document_type', 'no_detect', 'delete']) 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:10,代码来源:forms.py

示例2: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import SelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['document_type'] = forms.MultipleChoiceField(
            choices=[(t, t) for t in Document.objects
                .order_by().values_list('document_type', flat=True).distinct()],
            widget=forms.SelectMultiple(attrs={'class': 'chosen'}),
            required=False)
        self.fields = OrderedDict((k, self.fields[k])
                                  for k in ['document_type', 'no_detect', 'delete']) 
开发者ID:LexPredict,项目名称:lexpredict-contraxsuite,代码行数:11,代码来源:forms.py

示例3: test_default_not_populated_on_selectmultiple

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import SelectMultiple [as 别名]
def test_default_not_populated_on_selectmultiple(self):
        class PubForm(forms.ModelForm):
            mode = forms.CharField(required=False, widget=forms.SelectMultiple)

            class Meta:
                model = PublicationDefaults
                fields = ('mode',)

        # Empty data doesn't use the model default because an unselected
        # SelectMultiple doesn't have a value in HTML form submission.
        mf1 = PubForm({})
        self.assertEqual(mf1.errors, {})
        m1 = mf1.save(commit=False)
        self.assertEqual(m1.mode, '')
        self.assertEqual(m1._meta.get_field('mode').get_default(), 'di') 
开发者ID:nesdis,项目名称:djongo,代码行数:17,代码来源:tests.py

示例4: test_optgroup_select_multiple

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import SelectMultiple [as 别名]
def test_optgroup_select_multiple(self):
        widget = SelectMultiple(choices=(
            ('outer1', 'Outer 1'),
            ('Group "1"', (('inner1', 'Inner 1'), ('inner2', 'Inner 2'))),
        ))
        self.check_html(widget, 'nestchoice', ['outer1', 'inner2'], html=(
            """<select multiple name="nestchoice">
            <option value="outer1" selected>Outer 1</option>
            <optgroup label="Group &quot;1&quot;">
            <option value="inner1">Inner 1</option>
            <option value="inner2" selected>Inner 2</option>
            </optgroup>
            </select>"""
        )) 
开发者ID:nesdis,项目名称:djongo,代码行数:16,代码来源:test_selectmultiple.py

示例5: test_many_to_many

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import SelectMultiple [as 别名]
def test_many_to_many(self):
        self.assertFormfield(Band, 'members', forms.SelectMultiple) 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:tests.py

示例6: test_select_multiple_widget_cant_change_delete_related

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import SelectMultiple [as 别名]
def test_select_multiple_widget_cant_change_delete_related(self):
        rel = Individual._meta.get_field('parent').remote_field
        widget = forms.SelectMultiple()
        wrapper = widgets.RelatedFieldWidgetWrapper(
            widget, rel, widget_admin_site,
            can_add_related=True,
            can_change_related=True,
            can_delete_related=True,
        )
        self.assertTrue(wrapper.can_add_related)
        self.assertFalse(wrapper.can_change_related)
        self.assertFalse(wrapper.can_delete_related) 
开发者ID:nesdis,项目名称:djongo,代码行数:14,代码来源:tests.py


注:本文中的django.forms.SelectMultiple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。