{"record":{"id":"92f2922247de286a","repo":"pallets/flask","slug":"template","errorCode":null,"errorMessage":"{template}","messagePattern":"\\{template\\}","errorType":"exception","errorClass":"TemplateNotFound","httpStatus":null,"severity":"error","filePath":"src/flask/templating.py","lineNumber":86,"sourceCode":"        rv: tuple[str, str | None, t.Callable[[], bool] | None] | None\n        trv: None | (tuple[str, str | None, t.Callable[[], bool] | None]) = None\n\n        for srcobj, loader in self._iter_loaders(template):\n            try:\n                rv = loader.get_source(environment, template)\n                if trv is None:\n                    trv = rv\n            except TemplateNotFound:\n                rv = None\n            attempts.append((loader, srcobj, rv))\n\n        from .debughelpers import explain_template_loading_attempts\n\n        explain_template_loading_attempts(self.app, template, attempts)\n\n        if trv is not None:\n            return trv\n        raise TemplateNotFound(template)\n\n    def _get_source_fast(\n        self, environment: BaseEnvironment, template: str\n    ) -> tuple[str, str | None, t.Callable[[], bool] | None]:\n        for _srcobj, loader in self._iter_loaders(template):\n            try:\n                return loader.get_source(environment, template)\n            except TemplateNotFound:\n                continue\n        raise TemplateNotFound(template)\n\n    def _iter_loaders(self, template: str) -> t.Iterator[tuple[Scaffold, BaseLoader]]:\n        loader = self.app.jinja_loader\n        if loader is not None:\n            yield self.app, loader\n\n        for blueprint in self.app.iter_blueprints():\n            loader = blueprint.jinja_loader","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/pallets/flask/blob/3596b1ab61cea85edb8970e83ff61daa073facf8/src/flask/templating.py#L68-L104","documentation":"DispatchingJinjaLoader._get_source (the explanatory path) iterates the app then blueprints' jinja_loaders, attempts each, records attempts, calls explain_template_loading_attempts for debugging, and if no loader returned the template it raises TemplateNotFound(template). The message is just the template name; the real diagnostics are in the explained attempts logged before raising.","triggerScenarios":"render_template('missing.html'); render_template('sub/file.html') where the file is absent; a typo in the template name; templates folder misconfigured; blueprint template folder not set so the template is not found in any loader.","commonSituations":"Template file deleted or renamed; template_folder path wrong relative to the app root; case-sensitivity mismatch (especially deploying from macOS to Linux); blueprint templates expected under the wrong folder.","solutions":["Verify the template file exists under the app's template_folder (default templates/) or the blueprint's template_folder.","Enable EXPLAIN_TEMPLATE_LOADING or call explain_template_loading_attempts to see which loaders were tried.","Correct the template name spelling/case and the path passed to render_template.","For blueprint templates, set template_folder='templates' on the Blueprint and reference by name only."],"exampleFix":"// before\nreturn render_template('home.htm')  # typo\n\n// after\nreturn render_template('home.html')","handlingStrategy":"validation","validationCode":"from jinja2 import TemplateNotFound\n\ndef template_exists(app, name: str) -> bool:\n    try:\n        app.jinja_env.get_template(name)\n        return True\n    except TemplateNotFound:\n        return False\n","typeGuard":null,"tryCatchPattern":"try:\n    return render_template(name)\nexcept TemplateNotFound:\n    app.logger.error('template %s not found; tried loaders see EXPLAIN_TEMPLATE_LOADING', name)\n    abort(404)","preventionTips":["Enable EXPLAIN_TEMPLATE_LOADING in dev to see loaders tried.","Keep templates under app/templates (and bp/templates) and reference by name only.","Validate template names against the filesystem in CI."],"tags":["flask","templating","jinja2","template-not-found","configuration"],"backgroundTag":null,"analyzedSha":"3596b1ab61cea85edb8970e83ff61daa073facf8","analyzedAt":"2026-08-11T20:11:52.622Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}