xpleaf / Blog_mini

An Open Source Blog System that developed with Flask.
Other
983 stars 471 forks source link

UndefinedError: 'BlogInfo' is undefined #32

Open git-ruoshui opened 6 years ago

git-ruoshui commented 6 years ago

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 commented 6 years ago

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

git-ruoshui commented 6 years ago

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

xpleaf commented 6 years ago

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

git-ruoshui commented 6 years ago

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

xpleaf commented 6 years ago

OK