Flask raises TemplateNotFound error even though template file exists

前端 未结 11 1381
别跟我提以往
别跟我提以往 2020-11-21 23:02

I am trying to render the file home.html. The file exists in my project, but I keep getting jinja2.exceptions.TemplateNotFound: home.html when I t

11条回答
  •  礼貌的吻别
    2020-11-21 23:34

    Check that:

    1. the template file has the right name
    2. the template file is in a subdirectory called templates
    3. the name you pass to render_template is relative to the template directory (index.html would be directly in the templates directory, auth/login.html would be under the auth directory in the templates directory.)
    4. you either do not have a subdirectory with the same name as your app, or the templates directory is inside that subdir.

    If that doesn't work, turn on debugging (app.debug = True) which might help figure out what's wrong.

提交回复
热议问题