當前位置: 首頁>>代碼示例>>Python>>正文


Python widgets.SelectMultiple方法代碼示例

本文整理匯總了Python中django.forms.widgets.SelectMultiple方法的典型用法代碼示例。如果您正苦於以下問題:Python widgets.SelectMultiple方法的具體用法?Python widgets.SelectMultiple怎麽用?Python widgets.SelectMultiple使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.forms.widgets的用法示例。


在下文中一共展示了widgets.SelectMultiple方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def __init__(self, *args, **kwargs):
            super(Code.ComponentForm, self).__init__(*args, **kwargs)
            self.fields['description'].widget = Textarea(attrs={'cols': 50, 'rows': 5})
            self.fields['max_size'].widget = TextInput(attrs={'style':'width:5em'})
            self.fields['allowed'].widget = SelectMultiple(choices=CODE_TYPES, attrs={'style':'width:40em', 'size': 15})
            self.initial['allowed'] = self._initial_allowed 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:8,代碼來源:code.py

示例2: _initial_allowed

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def _initial_allowed(self):
            """
            Rework the comma-separated value into a list for the SelectMultiple initial value
            """
            if self.instance:
                return self.instance.allowed.split(',')
            else:
                return [] 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:10,代碼來源:code.py

示例3: __init__

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def __init__(self, *args, **kwargs):
            super(Office.ComponentForm, self).__init__(*args, **kwargs)
            self.fields['description'].widget = Textarea(attrs={'cols': 50, 'rows': 5})
            self.fields['allowed'].widget = SelectMultiple(choices=OFFICE_CHOICES, attrs={'style':'width:40em', 'size': 15})
            self.initial['allowed'] = self._initial_allowed 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:7,代碼來源:office.py

示例4: _initial_allowed

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def _initial_allowed(self):
            """
            Rework the comma-separated value into a list for the SelectMultiple initial value
            """
            if self.instance and 'types' in self.instance.allowed:
                return self.instance.allowed['types']
            else:
                return [] 
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:10,代碼來源:office.py

示例5: formfield_for_manytomany

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def formfield_for_manytomany(self, db_field, request=None, **kwargs):
        """
        Get a form Field for a ManyToManyField.
        """
        # If it uses an intermediary model that isn't auto created, don't show
        # a field in admin.
        if not db_field.rel.through._meta.auto_created:
            return None
        db = kwargs.get('using')

        if db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.rel,
                                    self.admin_site, using=db)
            kwargs['help_text'] = ''
        elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)):
            kwargs['widget'] = widgets.FilteredSelectMultiple(
                db_field.verbose_name,
                db_field.name in self.filter_vertical
            )

        if 'queryset' not in kwargs:
            queryset = self.get_field_queryset(db, db_field, request)
            if queryset is not None:
                kwargs['queryset'] = queryset

        form_field = db_field.formfield(**kwargs)
        if isinstance(form_field.widget, SelectMultiple) and not isinstance(form_field.widget, CheckboxSelectMultiple):
            msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.')
            help_text = form_field.help_text
            form_field.help_text = string_concat(help_text, ' ', msg) if help_text else msg
        return form_field 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:33,代碼來源:options.py

示例6: formfield_for_manytomany

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def formfield_for_manytomany(self, db_field, request, **kwargs):
        """
        Get a form Field for a ManyToManyField.
        """
        # If it uses an intermediary model that isn't auto created, don't show
        # a field in admin.
        if not db_field.remote_field.through._meta.auto_created:
            return None
        db = kwargs.get('using')

        autocomplete_fields = self.get_autocomplete_fields(request)
        if db_field.name in autocomplete_fields:
            kwargs['widget'] = AutocompleteSelectMultiple(db_field.remote_field, self.admin_site, using=db)
        elif db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
        elif db_field.name in list(self.filter_vertical) + list(self.filter_horizontal):
            kwargs['widget'] = widgets.FilteredSelectMultiple(
                db_field.verbose_name,
                db_field.name in self.filter_vertical
            )

        if 'queryset' not in kwargs:
            queryset = self.get_field_queryset(db, db_field, request)
            if queryset is not None:
                kwargs['queryset'] = queryset

        form_field = db_field.formfield(**kwargs)
        if (isinstance(form_field.widget, SelectMultiple) and
                not isinstance(form_field.widget, (CheckboxSelectMultiple, AutocompleteSelectMultiple))):
            msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.')
            help_text = form_field.help_text
            form_field.help_text = format_lazy('{} {}', help_text, msg) if help_text else msg
        return form_field 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:35,代碼來源:options.py

示例7: formfield_for_manytomany

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def formfield_for_manytomany(self, db_field, request, **kwargs):
        """
        Get a form Field for a ManyToManyField.
        """
        # If it uses an intermediary model that isn't auto created, don't show
        # a field in admin.
        if not db_field.remote_field.through._meta.auto_created:
            return None
        db = kwargs.get('using')

        if db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
        elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)):
            kwargs['widget'] = widgets.FilteredSelectMultiple(
                db_field.verbose_name,
                db_field.name in self.filter_vertical
            )

        if 'queryset' not in kwargs:
            queryset = self.get_field_queryset(db, db_field, request)
            if queryset is not None:
                kwargs['queryset'] = queryset

        form_field = db_field.formfield(**kwargs)
        if isinstance(form_field.widget, SelectMultiple) and not isinstance(form_field.widget, CheckboxSelectMultiple):
            msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.')
            help_text = form_field.help_text
            form_field.help_text = format_lazy('{} {}', help_text, msg) if help_text else msg
        return form_field 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:31,代碼來源:options.py

示例8: formfield_for_manytomany

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def formfield_for_manytomany(self, db_field, request=None, **kwargs):
        """
        Get a form Field for a ManyToManyField.
        """
        # If it uses an intermediary model that isn't auto created, don't show
        # a field in admin.
        if not db_field.remote_field.through._meta.auto_created:
            return None
        db = kwargs.get('using')

        if db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ManyToManyRawIdWidget(db_field.remote_field,
                                    self.admin_site, using=db)
            kwargs['help_text'] = ''
        elif db_field.name in (list(self.filter_vertical) + list(self.filter_horizontal)):
            kwargs['widget'] = widgets.FilteredSelectMultiple(
                db_field.verbose_name,
                db_field.name in self.filter_vertical
            )

        if 'queryset' not in kwargs:
            queryset = self.get_field_queryset(db, db_field, request)
            if queryset is not None:
                kwargs['queryset'] = queryset

        form_field = db_field.formfield(**kwargs)
        if isinstance(form_field.widget, SelectMultiple) and not isinstance(form_field.widget, CheckboxSelectMultiple):
            msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.')
            help_text = form_field.help_text
            form_field.help_text = string_concat(help_text, ' ', msg) if help_text else msg
        return form_field 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:33,代碼來源:options.py

示例9: __init__

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def __init__(self, choices, attrs=None):
        _widgets = (
            widgets.SelectMultiple(choices=choices, attrs=attrs),
            LabeledCheckboxInput(label=_('critical')),
        )
        super(MultiValueExtensionWidget, self).__init__(_widgets, attrs) 
開發者ID:mathiasertl,項目名稱:django-ca,代碼行數:8,代碼來源:widgets.py

示例10: __init__

# 需要導入模塊: from django.forms import widgets [as 別名]
# 或者: from django.forms.widgets import SelectMultiple [as 別名]
def __init__(self, name=None, distinct=False, **kwargs):
        kwargs.setdefault('method', self._filter)
        super(MultiValueFilter, self).__init__(widget=SelectMultiple, name=name, distinct=distinct, **kwargs) 
開發者ID:product-definition-center,項目名稱:product-definition-center,代碼行數:5,代碼來源:filters.py


注:本文中的django.forms.widgets.SelectMultiple方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。