MCPcopy
hub / github.com/django/django / __getitem__

Method __getitem__

django/template/utils.py:67–88  ·  view source on GitHub ↗
(self, alias)

Source from the content-addressed store, hash-verified

65 return templates
66
67 def __getitem__(self, alias):
68 try:
69 return self._engines[alias]
70 except KeyError:
71 try:
72 params = self.templates[alias]
73 except KeyError:
74 raise InvalidTemplateEngineError(
75 "Could not find config for '{}' "
76 "in settings.TEMPLATES".format(alias)
77 )
78
79 # If importing or initializing the backend raises an exception,
80 # self._engines[alias] isn't set and this code may get executed
81 # again, so we must preserve the original params. See #24265.
82 params = params.copy()
83 backend = params.pop("BACKEND")
84 engine_cls = import_string(backend)
85 engine = engine_cls(params)
86
87 self._engines[alias] = engine
88 return engine
89
90 def __iter__(self):
91 return iter(self.templates)

Callers

nothing calls this directly

Calls 5

import_stringFunction · 0.90
formatMethod · 0.45
copyMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected