Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UndefinedError: 'BlogInfo' is undefined #32

Open
git-ruoshui opened this issue Aug 13, 2018 · 5 comments
Open

UndefinedError: 'BlogInfo' is undefined #32

git-ruoshui opened this issue Aug 13, 2018 · 5 comments
Labels

Comments

@git-ruoshui
Copy link

File "d:\program files\python36\lib\site-packages\flask\app.py", line 2309, in call
return self.wsgi_app(environ, start_response)
File "d:\program files\python36\lib\site-packages\flask\app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "d:\program files\python36\lib\site-packages\flask\app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "d:\program files\python36\lib\site-packages\flask_compat.py", line 35, in reraise
raise value
File "d:\program files\python36\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "d:\program files\python36\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "d:\program files\python36\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "d:\program files\python36\lib\site-packages\flask_compat.py", line 35, in reraise
raise value
File "d:\program files\python36\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "d:\program files\python36\lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.view_functionsrule.endpoint
File "D:\pycharmwork\Blog_mini\app\main\views.py", line 20, in index
pagination=pagination, endpoint='.index')
File "d:\program files\python36\lib\site-packages\flask\templating.py", line 135, in render_template
context, ctx.app)
File "d:\program files\python36\lib\site-packages\flask\templating.py", line 117, in _render
rv = template.render(context)
File "d:\program files\python36\lib\site-packages\jinja2\asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "d:\program files\python36\lib\site-packages\jinja2\environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "d:\program files\python36\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "d:\program files\python36\lib\site-packages\jinja2_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "D:\pycharmwork\Blog_mini\app\templates\index.html", line 2, in top-level template code
{% import "_macros.html" as macros %}
File "D:\pycharmwork\Blog_mini\app\templates\base.html", line 8, in top-level template code
{% block title %}
File "D:\pycharmwork\Blog_mini\app\templates\base.html", line 9, in block "title"
{{ BlogInfo.query.first().title }}
File "d:\program files\python36\lib\site-packages\jinja2\environment.py", line 430, in getattr
return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'BlogInfo' is undefined

请问这是什么原因,,

@xpleaf
Copy link
Owner

xpleaf commented Sep 3, 2018

问题解决了吗?看到你是在win下跑的代码,这个不好确定,你debug一下,在渲染这个页面的时候,BlogInfo这个对象有没有传进去。

@xpleaf xpleaf added the question label Sep 3, 2018
@git-ruoshui
Copy link
Author

前段时间忙于其他事情,缺失在win上跑的,没有部署,其他数据库什么的都成功了,老是报这个错,不知道为啥,另外falsk版本我的是1.0.2的,里面的相关版本差异代码我已经改了,这个错误一直没解决

@xpleaf
Copy link
Owner

xpleaf commented Sep 3, 2018

嗯,如果都能跑起来的话,你debug一下这段出错的代码,看看是哪出的问题。

@git-ruoshui
Copy link
Author

多谢博主,是我的启动方式出了问题,现在可以了

@xpleaf
Copy link
Owner

xpleaf commented Sep 6, 2018

OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants