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


Python admin.GenericStackedInline方法代码示例

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


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

示例1: test_generic_inline_model_admin_non_generic_model

# 需要导入模块: from django.contrib.contenttypes import admin [as 别名]
# 或者: from django.contrib.contenttypes.admin import GenericStackedInline [as 别名]
def test_generic_inline_model_admin_non_generic_model(self):
        """
        A model without a GenericForeignKey raises problems if it's included
        in a GenericInlineModelAdmin definition.
        """
        class BookInline(GenericStackedInline):
            model = Book

        class SongAdmin(admin.ModelAdmin):
            inlines = [BookInline]

        errors = SongAdmin(Song, AdminSite()).check()
        expected = [
            checks.Error(
                "'admin_checks.Book' has no GenericForeignKey.",
                obj=BookInline,
                id='admin.E301',
            )
        ]
        self.assertEqual(errors, expected) 
开发者ID:nesdis,项目名称:djongo,代码行数:22,代码来源:tests.py

示例2: test_generic_inline_model_admin_bad_ct_field

# 需要导入模块: from django.contrib.contenttypes import admin [as 别名]
# 或者: from django.contrib.contenttypes.admin import GenericStackedInline [as 别名]
def test_generic_inline_model_admin_bad_ct_field(self):
        """
        A GenericInlineModelAdmin errors if the ct_field points to a
        nonexistent field.
        """
        class InfluenceInline(GenericStackedInline):
            model = Influence
            ct_field = 'nonexistent'

        class SongAdmin(admin.ModelAdmin):
            inlines = [InfluenceInline]

        errors = SongAdmin(Song, AdminSite()).check()
        expected = [
            checks.Error(
                "'ct_field' references 'nonexistent', which is not a field on 'admin_checks.Influence'.",
                obj=InfluenceInline,
                id='admin.E302',
            )
        ]
        self.assertEqual(errors, expected) 
开发者ID:nesdis,项目名称:djongo,代码行数:23,代码来源:tests.py

示例3: test_generic_inline_model_admin_bad_fk_field

# 需要导入模块: from django.contrib.contenttypes import admin [as 别名]
# 或者: from django.contrib.contenttypes.admin import GenericStackedInline [as 别名]
def test_generic_inline_model_admin_bad_fk_field(self):
        """
        A GenericInlineModelAdmin errors if the ct_fk_field points to a
        nonexistent field.
        """
        class InfluenceInline(GenericStackedInline):
            model = Influence
            ct_fk_field = 'nonexistent'

        class SongAdmin(admin.ModelAdmin):
            inlines = [InfluenceInline]

        errors = SongAdmin(Song, AdminSite()).check()
        expected = [
            checks.Error(
                "'ct_fk_field' references 'nonexistent', which is not a field on 'admin_checks.Influence'.",
                obj=InfluenceInline,
                id='admin.E303',
            )
        ]
        self.assertEqual(errors, expected) 
开发者ID:nesdis,项目名称:djongo,代码行数:23,代码来源:tests.py

示例4: test_generic_inline_model_admin_non_gfk_ct_field

# 需要导入模块: from django.contrib.contenttypes import admin [as 别名]
# 或者: from django.contrib.contenttypes.admin import GenericStackedInline [as 别名]
def test_generic_inline_model_admin_non_gfk_ct_field(self):
        """
        A GenericInlineModelAdmin raises problems if the ct_field points to a
        field that isn't part of a GenericForeignKey.
        """
        class InfluenceInline(GenericStackedInline):
            model = Influence
            ct_field = 'name'

        class SongAdmin(admin.ModelAdmin):
            inlines = [InfluenceInline]

        errors = SongAdmin(Song, AdminSite()).check()
        expected = [
            checks.Error(
                "'admin_checks.Influence' has no GenericForeignKey using "
                "content type field 'name' and object ID field 'object_id'.",
                obj=InfluenceInline,
                id='admin.E304',
            )
        ]
        self.assertEqual(errors, expected) 
开发者ID:nesdis,项目名称:djongo,代码行数:24,代码来源:tests.py

示例5: get_inline

# 需要导入模块: from django.contrib.contenttypes import admin [as 别名]
# 或者: from django.contrib.contenttypes.admin import GenericStackedInline [as 别名]
def get_inline(metadata_class):
    attrs = {
        'max_num': 1,
        'extra': 1,
        'model': metadata_class._meta.get_model('modelinstance'),
        'ct_field': "_content_type",
        'ct_fk_field': "_object_id",
        'formset': MetadataFormset,
    }
    return type('MetadataInline', (GenericStackedInline,), attrs) 
开发者ID:whyflyru,项目名称:django-seo,代码行数:12,代码来源:admin.py

示例6: get_inline

# 需要导入模块: from django.contrib.contenttypes import admin [as 别名]
# 或者: from django.contrib.contenttypes.admin import GenericStackedInline [as 别名]
def get_inline(metadata_class):
    attrs = {
        'max_num': 1,
        'extra': 1,
        'model': metadata_class._meta.get_model('modelinstance'),
        'ct_field': "_content_type",
        'ct_fk_field': "_object_id",
        'formset': MetadataFormset,
    }
    return type(str('MetadataInline'), (GenericStackedInline,), attrs) 
开发者ID:romansalin,项目名称:django-seo2,代码行数:12,代码来源:admin.py

示例7: test_valid_generic_inline_model_admin

# 需要导入模块: from django.contrib.contenttypes import admin [as 别名]
# 或者: from django.contrib.contenttypes.admin import GenericStackedInline [as 别名]
def test_valid_generic_inline_model_admin(self):
        """
        Regression test for #22034 - check that generic inlines don't look for
        normal ForeignKey relations.
        """
        class InfluenceInline(GenericStackedInline):
            model = Influence

        class SongAdmin(admin.ModelAdmin):
            inlines = [InfluenceInline]

        errors = SongAdmin(Song, AdminSite()).check()
        self.assertEqual(errors, []) 
开发者ID:nesdis,项目名称:djongo,代码行数:15,代码来源:tests.py


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