本文整理匯總了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)
示例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
示例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
示例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)