當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。