MCPcopy
hub / github.com/django/django / check_dependencies

Function check_dependencies

django/contrib/admin/checks.py:56–174  ·  view source on GitHub ↗

Check that the admin's dependencies are correctly installed.

(**kwargs)

Source from the content-addressed store, hash-verified

54
55
56def check_dependencies(**kwargs):
57 """
58 Check that the admin's dependencies are correctly installed.
59 """
60 from django.contrib.admin.sites import all_sites
61
62 if not apps.is_installed("django.contrib.admin"):
63 return []
64 errors = []
65 app_dependencies = (
66 ("django.contrib.contenttypes", 401),
67 ("django.contrib.auth", 405),
68 ("django.contrib.messages", 406),
69 )
70 for app_name, error_code in app_dependencies:
71 if not apps.is_installed(app_name):
72 errors.append(
73 checks.Error(
74 "'%s' must be in INSTALLED_APPS in order to use the admin "
75 "application." % app_name,
76 id="admin.E%d" % error_code,
77 )
78 )
79 for engine in engines.all():
80 if isinstance(engine, DjangoTemplates):
81 django_templates_instance = engine.engine
82 break
83 else:
84 django_templates_instance = None
85 if not django_templates_instance:
86 errors.append(
87 checks.Error(
88 "A 'django.template.backends.django.DjangoTemplates' instance "
89 "must be configured in TEMPLATES in order to use the admin "
90 "application.",
91 id="admin.E403",
92 )
93 )
94 else:
95 if (
96 "django.contrib.auth.context_processors.auth"
97 not in django_templates_instance.context_processors
98 and _contains_subclass(
99 "django.contrib.auth.backends.ModelBackend",
100 settings.AUTHENTICATION_BACKENDS,
101 )
102 ):
103 errors.append(
104 checks.Error(
105 "'django.contrib.auth.context_processors.auth' must be "
106 "enabled in DjangoTemplates (TEMPLATES) if using the default "
107 "auth backend in order to use the admin application.",
108 id="admin.E402",
109 )
110 )
111 if (
112 "django.contrib.messages.context_processors.messages"
113 not in django_templates_instance.context_processors

Callers

nothing calls this directly

Calls 4

_contains_subclassFunction · 0.85
is_installedMethod · 0.80
appendMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected