MCPcopy
hub / github.com/django/django / _subclass_index

Function _subclass_index

django/contrib/auth/checks.py:11–24  ·  view source on GitHub ↗

Return the index of dotted class path (or a subclass of that class) in a list of candidate paths. If it does not exist, return -1.

(class_path, candidate_paths)

Source from the content-addressed store, hash-verified

9
10
11def _subclass_index(class_path, candidate_paths):
12 """
13 Return the index of dotted class path (or a subclass of that class) in a
14 list of candidate paths. If it does not exist, return -1.
15 """
16 cls = import_string(class_path)
17 for index, path in enumerate(candidate_paths):
18 try:
19 candidate_cls = import_string(path)
20 if issubclass(candidate_cls, cls):
21 return index
22 except (ImportError, TypeError):
23 continue
24 return -1
25
26
27def check_user_model(app_configs, **kwargs):

Callers 1

check_middlewareFunction · 0.85

Calls 1

import_stringFunction · 0.90

Tested by

no test coverage detected