本文整理汇总了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)