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


Python admin.StackedInline方法代码示例

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


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

示例1: test_exclude_inline_model_admin

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import StackedInline [as 别名]
def test_exclude_inline_model_admin(self):
        """
        Regression test for #9932 - exclude in InlineModelAdmin should not
        contain the ForeignKey field used in ModelAdmin.model
        """
        class SongInline(admin.StackedInline):
            model = Song
            exclude = ['album']

        class AlbumAdmin(admin.ModelAdmin):
            model = Album
            inlines = [SongInline]

        errors = AlbumAdmin(Album, AdminSite()).check()
        expected = [
            checks.Error(
                "Cannot exclude the field 'album', because it is the foreign key "
                "to the parent model 'admin_checks.Album'.",
                obj=SongInline,
                id='admin.E201',
            )
        ]
        self.assertEqual(errors, expected) 
开发者ID:nesdis,项目名称:djongo,代码行数:25,代码来源:tests.py

示例2: make_inline

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import StackedInline [as 别名]
def make_inline(model_, extra_=0):
    class Inline(admin.StackedInline):
        model = model_
        extra = extra_

    return Inline 
开发者ID:chaoss,项目名称:prospector,代码行数:8,代码来源:admin.py

示例3: test_stackedmodel_admin

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import StackedInline [as 别名]
def test_stackedmodel_admin(cls):
        """Tests whether :see:LocalizedFieldsAdminMixin mixin are works with
        admin.StackedInline."""

        class TestModelStackedInline(
            LocalizedFieldsAdminMixin, admin.StackedInline
        ):
            model = cls.TestModel

        @admin.register(cls.TestRelModel)
        class TestRelModelAdmin(admin.ModelAdmin):
            inlines = [TestModelStackedInline]

        assert len(check_admin_app(apps.get_app_configs())) == 0 
开发者ID:SectorLabs,项目名称:django-localized-fields,代码行数:16,代码来源:test_admin.py

示例4: get_queryset

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import StackedInline [as 别名]
def get_queryset(self, request):
        """
        Override MultitenantAdminMixin.get_queryset() because it breaks
        """
        return super(admin.StackedInline, self).get_queryset(request) 
开发者ID:openwisp,项目名称:openwisp-controller,代码行数:7,代码来源:admin.py


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