weijiang1994 / Blogin

A blog system depend on flask.使用flask框架开发的个人博客系统.
https://2dogz.cn
GNU General Public License v3.0
509 stars 99 forks source link

jinja2.exceptions.TemplateNotFound: main/index.html #30

Closed sci2sci closed 1 year ago

sci2sci commented 1 year ago

我把根文件名改成scisci后,然后flask run 后是这个问题

jinja2.exceptions.TemplateNotFound: main/index.html

`File "/Users/xx/PycharmProjects/SciSci/scisci/blueprint/front/blog.py", line 45, in index
    plans = Plan.query.filter_by(is_done=0).all()
    su = User.query.filter(User.email == 'sciscipaper@gmail.com').first()
    flinks = FriendLink.query.filter(FriendLink.flag == 1).all()
    msg_borders = MessageBorder.query.filter(MessageBorder.flag == 0, MessageBorder.parent_id == 0
                                             ).order_by(MessageBorder.timestamps.desc()).all()[0:5]
    return render_template('main/index.html', per_page=current_app.config['BLOGIN_BLOG_PER_PAGE'],
                           pagination=pagination, blogs=blogs, cates=cates, categories=categories,
                           loves=loves, su=su, flinks=flinks, plans=plans, msg_borders=msg_borders)

@blog_bp.route('/themes/<string:theme_name>/')
weijiang1994 commented 1 year ago

没有找到模板文件,你看看template目录下面有没有

sci2sci commented 1 year ago

main @weijiang1994 有啊 我不知道为啥上次就OK 我改一下目录文件名scisci就出现问题啦 我在SciSci

weijiang1994 commented 1 year ago

把.flaskenv文件的APP改成scisci

sci2sci commented 1 year ago

FLASK_APP=scisci FLASK_ENV=development

sci2sci commented 1 year ago

改了 很奇怪

weijiang1994 commented 1 year ago

看看你的目录结构

sci2sci commented 1 year ago

s

sci2sci commented 1 year ago

File "/Users/kxx/PycharmProjects/SciSci/sci/lib/python3.8/site-packages/flask/templating.py", line 89, in _get_source_fast raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: main/index.html

weijiang1994 commented 1 year ago

那你指定一下template的路径试一下

sci2sci commented 1 year ago

jinja2.exceptions.TemplateNotFound: /Users/xx/PycharmProjects/SciSci/scisci/templates/main/index.html

sci2sci commented 1 year ago

一样的问题啊

sci2sci commented 1 year ago

我刚才把文件名所有的blogin代替成scisci就上面问题消失啦。但是又有问题 KeyError KeyError: 'scisci_BLOG_PER_PAGE'

我估计这哪里设置一下

sci2sci commented 1 year ago

难道这个scisci必须大写吗

sci2sci commented 1 year ago

urrent_app.config <Config {'ENV': 'development', 'DEBUG': True, 'TESTING': False, 'PROPAGATE_EXCEPTIONS': None, '

sci2sci commented 1 year ago

上面没有那些设置scisci_BLOG_PER_PAGE = 8 scisci_COMMENT_PER_PAGE = 10 scisci_PHOTO_PER_PAGE = 12

我把那个scisci改成大写就可以。

为啥会发生这种情况 一大写就OK啊。

sci2sci commented 1 year ago

为啥 说不能提交包含空的表单!

我看你的default就可以啊