當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。