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


Python options.VERTICAL屬性代碼示例

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


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

示例1: _check_radio_fields_value

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def _check_radio_fields_value(self, cls, model, val, label):
        """ Check type of a value of `radio_fields` dictionary. """

        from django.contrib.admin.options import HORIZONTAL, VERTICAL

        if val not in (HORIZONTAL, VERTICAL):
            return [
                checks.Error(
                    "The value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL." % label,
                    hint=None,
                    obj=cls,
                    id='admin.E024',
                )
            ]
        else:
            return [] 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:18,代碼來源:checks.py

示例2: _check_radio_fields_value

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def _check_radio_fields_value(self, obj, val, label):
        """ Check type of a value of `radio_fields` dictionary. """

        from django.contrib.admin.options import HORIZONTAL, VERTICAL

        if val not in (HORIZONTAL, VERTICAL):
            return [
                checks.Error(
                    "The value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL." % label,
                    hint=None,
                    obj=obj.__class__,
                    id='admin.E024',
                )
            ]
        else:
            return [] 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:18,代碼來源:checks.py

示例3: validate_radio_fields

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def validate_radio_fields(self, cls, model):
        " Validate that radio_fields is a dictionary of choice or foreign key fields. "
        from django.contrib.admin.options import HORIZONTAL, VERTICAL
        if hasattr(cls, 'radio_fields'):
            check_isdict(cls, 'radio_fields', cls.radio_fields)
            for field, val in cls.radio_fields.items():
                f = get_field(cls, model, 'radio_fields', field)
                if not (isinstance(f, models.ForeignKey) or f.choices):
                    raise ImproperlyConfigured("'%s.radio_fields['%s']' "
                            "is neither an instance of ForeignKey nor does "
                            "have choices set." % (cls.__name__, field))
                if val not in (HORIZONTAL, VERTICAL):
                    raise ImproperlyConfigured("'%s.radio_fields['%s']' "
                            "is neither admin.HORIZONTAL nor admin.VERTICAL."
                            % (cls.__name__, field)) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:17,代碼來源:validation.py

示例4: _check_radio_fields_value

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def _check_radio_fields_value(self, obj, val, label):
        """ Check type of a value of `radio_fields` dictionary. """

        from django.contrib.admin.options import HORIZONTAL, VERTICAL

        if val not in (HORIZONTAL, VERTICAL):
            return [
                checks.Error(
                    "The value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL." % label,
                    obj=obj.__class__,
                    id='admin.E024',
                )
            ]
        else:
            return [] 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:17,代碼來源:checks.py

示例5: test_missing_field

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def test_missing_field(self):
        class TestModelAdmin(ModelAdmin):
            radio_fields = {'non_existent_field': VERTICAL}

        self.assertIsInvalid(
            TestModelAdmin, ValidationTestModel,
            "The value of 'radio_fields' refers to 'non_existent_field', "
            "which is not an attribute of 'modeladmin.ValidationTestModel'.",
            'admin.E022'
        ) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:12,代碼來源:test_checks.py

示例6: test_invalid_field_type

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def test_invalid_field_type(self):
        class TestModelAdmin(ModelAdmin):
            radio_fields = {'name': VERTICAL}

        self.assertIsInvalid(
            TestModelAdmin, ValidationTestModel,
            "The value of 'radio_fields' refers to 'name', which is not an instance "
            "of ForeignKey, and does not have a 'choices' definition.",
            'admin.E023'
        ) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:12,代碼來源:test_checks.py

示例7: test_invalid_value

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def test_invalid_value(self):
        class TestModelAdmin(ModelAdmin):
            radio_fields = {'state': None}

        self.assertIsInvalid(
            TestModelAdmin, ValidationTestModel,
            "The value of 'radio_fields[\"state\"]' must be either admin.HORIZONTAL or admin.VERTICAL.",
            'admin.E024'
        ) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:11,代碼來源:test_checks.py

示例8: test_valid_case

# 需要導入模塊: from django.contrib.admin import options [as 別名]
# 或者: from django.contrib.admin.options import VERTICAL [as 別名]
def test_valid_case(self):
        class TestModelAdmin(ModelAdmin):
            radio_fields = {'state': VERTICAL}

        self.assertIsValid(TestModelAdmin, ValidationTestModel) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:7,代碼來源:test_checks.py


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