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


Python widgets.AdminRadioSelect方法代碼示例

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


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

示例1: formfield_for_choice_field

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def formfield_for_choice_field(self, db_field, request=None, **kwargs):
        """
        Get a form Field for a database Field that has declared choices.
        """
        # If the field is named as a radio_field, use a RadioSelect
        if db_field.name in self.radio_fields:
            # Avoid stomping on custom widget/choices arguments.
            if 'widget' not in kwargs:
                kwargs['widget'] = widgets.AdminRadioSelect(attrs={
                    'class': get_ul_class(self.radio_fields[db_field.name]),
                })
            if 'choices' not in kwargs:
                kwargs['choices'] = db_field.get_choices(
                    include_blank=db_field.blank,
                    blank_choice=[('', _('None'))]
                )
        return db_field.formfield(**kwargs) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:19,代碼來源:options.py

示例2: formfield_for_foreignkey

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
        """
        Get a form Field for a ForeignKey.
        """
        db = kwargs.get('using')
        if db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.rel,
                                    self.admin_site, using=db)
        elif db_field.name in self.radio_fields:
            kwargs['widget'] = widgets.AdminRadioSelect(attrs={
                'class': get_ul_class(self.radio_fields[db_field.name]),
            })
            kwargs['empty_label'] = _('None') if db_field.blank else None

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

        return db_field.formfield(**kwargs) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:22,代碼來源:options.py

示例3: formfield_for_choice_field

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def formfield_for_choice_field(self, db_field, request, **kwargs):
        """
        Get a form Field for a database Field that has declared choices.
        """
        # If the field is named as a radio_field, use a RadioSelect
        if db_field.name in self.radio_fields:
            # Avoid stomping on custom widget/choices arguments.
            if 'widget' not in kwargs:
                kwargs['widget'] = widgets.AdminRadioSelect(attrs={
                    'class': get_ul_class(self.radio_fields[db_field.name]),
                })
            if 'choices' not in kwargs:
                kwargs['choices'] = db_field.get_choices(
                    include_blank=db_field.blank,
                    blank_choice=[('', _('None'))]
                )
        return db_field.formfield(**kwargs) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:19,代碼來源:options.py

示例4: formfield_for_foreignkey

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def formfield_for_foreignkey(self, db_field, request, **kwargs):
        """
        Get a form Field for a ForeignKey.
        """
        db = kwargs.get('using')

        if db_field.name in self.get_autocomplete_fields(request):
            kwargs['widget'] = AutocompleteSelect(db_field.remote_field, self.admin_site, using=db)
        elif db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
        elif db_field.name in self.radio_fields:
            kwargs['widget'] = widgets.AdminRadioSelect(attrs={
                'class': get_ul_class(self.radio_fields[db_field.name]),
            })
            kwargs['empty_label'] = _('None') if db_field.blank else None

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

        return db_field.formfield(**kwargs) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:24,代碼來源:options.py

示例5: formfield_for_foreignkey

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def formfield_for_foreignkey(self, db_field, request, **kwargs):
        """
        Get a form Field for a ForeignKey.
        """
        db = kwargs.get('using')
        if db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.remote_field, self.admin_site, using=db)
        elif db_field.name in self.radio_fields:
            kwargs['widget'] = widgets.AdminRadioSelect(attrs={
                'class': get_ul_class(self.radio_fields[db_field.name]),
            })
            kwargs['empty_label'] = _('None') if db_field.blank else None

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

        return db_field.formfield(**kwargs) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:21,代碼來源:options.py

示例6: formfield_for_foreignkey

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
        """
        Get a form Field for a ForeignKey.
        """
        db = kwargs.get('using')
        if db_field.name in self.raw_id_fields:
            kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.remote_field,
                                    self.admin_site, using=db)
        elif db_field.name in self.radio_fields:
            kwargs['widget'] = widgets.AdminRadioSelect(attrs={
                'class': get_ul_class(self.radio_fields[db_field.name]),
            })
            kwargs['empty_label'] = _('None') if db_field.blank else None

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

        return db_field.formfield(**kwargs) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:22,代碼來源:options.py

示例7: test_radio_fields_ForeignKey

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def test_radio_fields_ForeignKey(self):
        ff = self.assertFormfield(Event, 'main_band', widgets.AdminRadioSelect,
                                  radio_fields={'main_band': admin.VERTICAL})
        self.assertIsNone(ff.empty_label) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:6,代碼來源:tests.py

示例8: test_choices_with_radio_fields

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def test_choices_with_radio_fields(self):
        self.assertFormfield(Member, 'gender', widgets.AdminRadioSelect,
                             radio_fields={'gender': admin.VERTICAL}) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:5,代碼來源:tests.py

示例9: test_no_can_add_related

# 需要導入模塊: from django.contrib.admin import widgets [as 別名]
# 或者: from django.contrib.admin.widgets import AdminRadioSelect [as 別名]
def test_no_can_add_related(self):
        rel = Individual._meta.get_field('parent').remote_field
        w = widgets.AdminRadioSelect()
        # Used to fail with a name error.
        w = widgets.RelatedFieldWidgetWrapper(w, rel, widget_admin_site)
        self.assertFalse(w.can_add_related) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:8,代碼來源:tests.py


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