本文整理汇总了Python中django.contrib.admin.options.InlineModelAdmin方法的典型用法代码示例。如果您正苦于以下问题:Python options.InlineModelAdmin方法的具体用法?Python options.InlineModelAdmin怎么用?Python options.InlineModelAdmin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.contrib.admin.options
的用法示例。
在下文中一共展示了options.InlineModelAdmin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _check_inlines_item
# 需要导入模块: from django.contrib.admin import options [as 别名]
# 或者: from django.contrib.admin.options import InlineModelAdmin [as 别名]
def _check_inlines_item(self, obj, model, inline, label):
""" Check one inline model admin. """
inline_label = inline.__module__ + '.' + inline.__name__
from django.contrib.admin.options import InlineModelAdmin
if not issubclass(inline, InlineModelAdmin):
return [
checks.Error(
"'%s' must inherit from 'InlineModelAdmin'." % inline_label,
obj=obj.__class__,
id='admin.E104',
)
]
elif not inline.model:
return [
checks.Error(
"'%s' must have a 'model' attribute." % inline_label,
obj=obj.__class__,
id='admin.E105',
)
]
elif not issubclass(inline.model, models.Model):
return must_be('a Model', option='%s.model' % inline_label, obj=obj, id='admin.E106')
else:
return inline(model, obj.admin_site).check()
示例2: _check_inlines_item
# 需要导入模块: from django.contrib.admin import options [as 别名]
# 或者: from django.contrib.admin.options import InlineModelAdmin [as 别名]
def _check_inlines_item(self, obj, model, inline, label):
""" Check one inline model admin. """
inline_label = '.'.join([inline.__module__, inline.__name__])
from django.contrib.admin.options import InlineModelAdmin
if not issubclass(inline, InlineModelAdmin):
return [
checks.Error(
"'%s' must inherit from 'InlineModelAdmin'." % inline_label,
obj=obj.__class__,
id='admin.E104',
)
]
elif not inline.model:
return [
checks.Error(
"'%s' must have a 'model' attribute." % inline_label,
obj=obj.__class__,
id='admin.E105',
)
]
elif not issubclass(inline.model, models.Model):
return must_be('a Model', option='%s.model' % inline_label, obj=obj, id='admin.E106')
else:
return inline(model, obj.admin_site).check()