MCPcopy
hub / github.com/django/django / _check_inlines_item

Method _check_inlines_item

django/contrib/admin/checks.py:879–915  ·  view source on GitHub ↗

Check one inline model admin.

(self, obj, inline, label)

Source from the content-addressed store, hash-verified

877 )
878
879 def _check_inlines_item(self, obj, inline, label):
880 """Check one inline model admin."""
881 try:
882 inline_label = inline.__module__ + "." + inline.__name__
883 except AttributeError:
884 return [
885 checks.Error(
886 "'%s' must inherit from 'InlineModelAdmin'." % obj,
887 obj=obj.__class__,
888 id="admin.E104",
889 )
890 ]
891
892 from django.contrib.admin.options import InlineModelAdmin
893
894 if not _issubclass(inline, InlineModelAdmin):
895 return [
896 checks.Error(
897 "'%s' must inherit from 'InlineModelAdmin'." % inline_label,
898 obj=obj.__class__,
899 id="admin.E104",
900 )
901 ]
902 elif not inline.model:
903 return [
904 checks.Error(
905 "'%s' must have a 'model' attribute." % inline_label,
906 obj=obj.__class__,
907 id="admin.E105",
908 )
909 ]
910 elif not _issubclass(inline.model, models.Model):
911 return must_be(
912 "a Model", option="%s.model" % inline_label, obj=obj, id="admin.E106"
913 )
914 else:
915 return inline(obj.model, obj.admin_site).check()
916
917 def _check_list_display(self, obj):
918 """Check list_display only contains fields or usable attributes."""

Callers 15

__exit__Method · 0.95
create_modelMethod · 0.95
delete_modelMethod · 0.95
add_indexMethod · 0.95
remove_indexMethod · 0.95
rename_indexMethod · 0.95
add_constraintMethod · 0.95
remove_constraintMethod · 0.95
alter_unique_togetherMethod · 0.95
alter_index_togetherMethod · 0.95
alter_db_tableMethod · 0.95

Calls 3

_issubclassFunction · 0.85
must_beFunction · 0.85
checkMethod · 0.45

Tested by

no test coverage detected