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


Python forms.CheckboxSelectMultiple方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['emri'].widget.attrs.update({'class': 'form-control'})

            

# class LendetForm(forms.ModelForm):

#     class Meta:
#         model = ProvimetMundshme
#         fields = '__all__'

#     def __init__(self, *args, **kwargs):
#         super().__init__(*args, **kwargs)
#         self.fields['program'].widget.attrs.update({'class': 'form-control', 'data-type': 'program-listener'})
#         self.fields['semester'].widget.attrs.update({'class': 'form-control'})
#         self.fields['year'].widget.attrs.update({'class': 'form-control'})
#         self.fields['level'].widget.attrs.update({'class': 'form-control'})

#     course = forms.MultipleChoiceField(
#         widget=forms.CheckboxSelectMultiple,
#         choices=[(c.pk, c.name) for c in Course.objects.all()],
#     ) 
开发者ID:urankajtazaj,项目名称:SEMS,代码行数:25,代码来源:forms.py

示例2: make_entry_field

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def make_entry_field(self, fieldsubmission=None):

        the_choices = [(k, v) for k, v in self.config.items() if k.startswith("choice_") and self.config[k]]
        the_choices = sorted(the_choices, key=lambda choice: (int) (re.findall(r'\d+', choice[0])[0]))

        initial = []

        if fieldsubmission:
            initial=fieldsubmission.data['info']

        c = self.CustomMultipleChoiceField(required=self.config['required'],
            label=self.config['label'],
            help_text=self.config['help_text'],
            choices=the_choices,
            widget=forms.CheckboxSelectMultiple(),
            initial=initial)

        return c 
开发者ID:sfu-fas,项目名称:coursys,代码行数:20,代码来源:select.py

示例3: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, project, *args, **kwargs):
        kwargs.setdefault('label_suffix', '')
        super(SiteBulkEditForm, self).__init__(*args, **kwargs)

        self.fields['sites'] = forms.ModelMultipleChoiceField(
            widget=forms.CheckboxSelectMultiple,
            queryset=project.sites.all(),
        )

        for attr in project.site_meta_attributes:
            q_type = attr['question_type']
            q_name = attr['question_name']

            if q_type == 'Number':
                field = forms.FloatField()
            elif q_type == 'Date':
                field = forms.DateField()
            elif q_type == 'MCQ':
                options = attr.get('mcq_options') or []
                choices = [o.get('option_text') for o in options]
                choices = [(c, c) for c in choices]
                field = forms.ChoiceField(choices=choices)
            else:
                field = forms.CharField()

            self.fields[q_name] = field 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:28,代码来源:forms.py

示例4: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        if settings.TARGET_PERMISSIONS_ONLY:
            self.common_layout = Layout('facility', 'target_id', 'observation_type')
        else:
            self.fields['groups'] = forms.ModelMultipleChoiceField(Group.objects.none(),
                                                                   required=False,
                                                                   widget=forms.CheckboxSelectMultiple)
            self.common_layout = Layout('facility', 'target_id', 'observation_type', 'groups')
        self.helper.layout = Layout(
            self.common_layout,
            self.layout(),
            self.button_layout()
        ) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:17,代码来源:facility.py

示例5: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        if not settings.TARGET_PERMISSIONS_ONLY:
            self.fields['groups'] = forms.ModelMultipleChoiceField(Group.objects.none(),
                                                                   required=False,
                                                                   widget=forms.CheckboxSelectMultiple) 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:8,代码来源:forms.py

示例6: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, referral_location_qs, *args, **kwargs):
        super(ReferralForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.fields['location'].widget = forms.widgets.CheckboxSelectMultiple()
        self.fields['location'].queryset = referral_location_qs
        self.helper.add_input(Submit('submit', 'Create referral')) 
开发者ID:SaturdayNeighborhoodHealthClinic,项目名称:osler,代码行数:8,代码来源:forms.py

示例7: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        settings = kwargs.pop('settings', None)
        super(GeneratedPluginSettingForm, self).__init__(*args, **kwargs)

        for field in settings:

            object = field['object']
            if field['types'] == 'char':
                self.fields[field['name']] = forms.CharField(widget=forms.TextInput(), required=False)
            elif field['types'] == 'rich-text' or field['types'] == 'text' or field['types'] == 'Text':
                self.fields[field['name']] = forms.CharField(widget=forms.Textarea, required=False)
            elif field['types'] == 'json':
                self.fields[field['name']] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                                                       choices=field['choices'],
                                                                       required=False)
            elif field['types'] == 'number':
                self.fields[field['name']] = forms.CharField(widget=forms.TextInput(attrs={'type': 'number'}))
            elif field['types'] == 'select':
                self.fields[field['name']] = forms.CharField(widget=forms.Select(choices=field['choices']))
            elif field['types'] == 'date':
                self.fields[field['name']] = forms.CharField(
                    widget=forms.DateInput(attrs={'class': 'datepicker'}))
            elif field['types'] == 'boolean':
                self.fields[field['name']] = forms.BooleanField(
                    widget=forms.CheckboxInput(attrs={'is_checkbox': True}),
                    required=False)

            self.fields[field['name']].initial = object.processed_value
            self.fields[field['name']].help_text = object.setting.description 
开发者ID:BirkbeckCTP,项目名称:janeway,代码行数:31,代码来源:forms.py

示例8: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields['groups'].widget = forms.CheckboxSelectMultiple()
        self.fields['groups'].queryset = Group.objects.all() 
开发者ID:wagtail,项目名称:wagtail,代码行数:7,代码来源:view_restrictions.py

示例9: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, poll, user=None, *args, **kwargs):
        super(PollVoteManyForm, self).__init__(*args, **kwargs)
        self.auto_id = 'id_poll_{pk}_%s'.format(pk=poll.pk)  # Uniqueness "<label for=id_poll_pk_..."
        self.user = user
        self.poll = poll
        self.poll_choices = getattr(poll, 'choices', poll.poll_choices.unremoved())
        choices = ((c.pk, mark_safe(c.description)) for c in self.poll_choices)

        if poll.is_multiple_choice:
            self.fields['choices'] = forms.MultipleChoiceField(
                choices=choices,
                widget=forms.CheckboxSelectMultiple,
                label=_("Poll choices")
            )
        else:
            self.fields['choices'] = forms.ChoiceField(
                choices=choices,
                widget=forms.RadioSelect,
                label=_("Poll choices")
            ) 
开发者ID:nitely,项目名称:Spirit,代码行数:22,代码来源:forms.py

示例10: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, topic, *args, **kwargs):
        super(CommentMoveForm, self).__init__(*args, **kwargs)
        self.fields['comments'] = forms.ModelMultipleChoiceField(
            queryset=Comment.objects.filter(topic=topic),
            widget=forms.CheckboxSelectMultiple
        ) 
开发者ID:nitely,项目名称:Spirit,代码行数:8,代码来源:forms.py

示例11: test_formfield

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def test_formfield(self):
        field = self.get_field(HookSelectModel, "hooks")
        formfield = field.formfield()
        self.assertTrue(isinstance(formfield, HookMultiSelectFormField))
        self.assertTrue(isinstance(formfield.widget, CheckboxSelectMultiple))
        self.assertEqual(
            formfield.choices,
            [("save_form_submission_data", "Save form submission data")],
        ) 
开发者ID:labd,项目名称:wagtailstreamforms,代码行数:11,代码来源:test_hook_select_field.py

示例12: is_checkbox

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def is_checkbox(boundfield):
    """Return True if this field's widget is a CheckboxInput."""
    widget = boundfield.field.widget
    is_checkbox_input = isinstance(widget, forms.CheckboxInput)
    is_checkbox_select = isinstance(widget, forms.CheckboxSelectMultiple)
    return is_checkbox_input or is_checkbox_select 
开发者ID:eventoL,项目名称:eventoL,代码行数:8,代码来源:filters.py

示例13: test_is_checkbox_with_CheckboxSelectMultiple_return_true

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def test_is_checkbox_with_CheckboxSelectMultiple_return_true(mocker):
    boundfield = mocker.Mock()
    boundfield.field = mocker.Mock()
    boundfield.field.widget = forms.CheckboxSelectMultiple()
    assert filters.is_checkbox(boundfield) 
开发者ID:eventoL,项目名称:eventoL,代码行数:7,代码来源:test_templatetag_filters.py

示例14: __init__

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        super(ProfileForm, self).__init__(*args, **kwargs)

        self.fields['full_name'] = forms.CharField(
            max_length=30,
            initial=self.user.full_name,
            widget=forms.TextInput(attrs={
                'placeholder': _('Name'),
            }),
            error_messages={
                'required': _('Please enter your full name.')
            })

        self.fields['bio'] = forms.CharField(
            initial=self.user.bio,
            widget=forms.Textarea(attrs={
                'class': 'bio',
                'placeholder': _('Add some details about yourself...'),
                'rows': 'auto',
            }),
            required=False)

        roles = Role.objects.all()
        self.fields['roles'] = RoleModelMultipleChoiceField(
            initial=self.user.roles.all(),
            queryset=roles,
            widget=forms.CheckboxSelectMultiple(),
            required=False) 
开发者ID:nlhkabu,项目名称:connect,代码行数:31,代码来源:forms.py

示例15: test_generates_checkbox

# 需要导入模块: from django import forms [as 别名]
# 或者: from django.forms import CheckboxSelectMultiple [as 别名]
def test_generates_checkbox(self):
        field = mocks.MockQuestion(self.question.serialized).make_field()
        self.assertEqual(len(field.choices), 5)
        self.assertEqual(field.choices[4][1], "This is choice 4")
        self.assertIsInstance(field.widget, forms.CheckboxSelectMultiple) 
开发者ID:project-callisto,项目名称:callisto-core,代码行数:7,代码来源:test_models.py


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