flask开发中遇到jinja2.exceptions.UndefinedError: 'flask_
发布时间:2020-12-17 17:03:44 所属栏目:Python 来源:网络整理
导读:?flask开发中遇到jinja2.exceptions.UndefinedError: 'flask_moment._moment object' has no attribute 'formNow 这句话的意思是在这个网页的jinja2模板中有一个单词写错 {%?extends?"base.html"?%}{%?import?"bootstrap/wtf.html"?as?wtf?%}{%?block?title?
?flask开发中遇到jinja2.exceptions.UndefinedError: 'flask_moment._moment object' has no attribute 'formNow 这句话的意思是在这个网页的jinja2模板中有一个单词写错 {%?extends?"base.html"?%} {%?import?"bootstrap/wtf.html"?as?wtf?%} {%?block?title?%}Flasky{%?endblock?%} {%?block?page_content?%} <div?class="page-header"> ????<h1>Hello,?{%?if?current_user.is_authenticated?%} ????????{{?current_user.username?}} ????????{%?else?%} ????????Stranger ????????{%?endif?%} ????!</h1> ????<!--如果该用户信息存在数据库--> ????{%?if??known?%} ????<p>非常高兴再次看见你</p> ????{%?else?%} ????<p>很高兴认识你</p> ????{%?endif?%} </div> <div> ????{%?if?current_user.can(Permission.WRITE_ARTICLES)?%} ????????{{?wtf.quick_form(form)?}} ????{%?endif?%} </div> <ul?class="posts"> ????{%?for?post?in?posts?%} ????<li?class="post"> ????????<div?class="post-thumbnail"> ????????????<a?href="{{?url_for(".user",?username=post.author.username)?}}"> ????????????????<img?class="img-rounded?profile-thumbnail"?src="{{?post.author.gravatar(size=40)?}}"> ????????????</a> ????????????<div?class="post-data">{{?moment(post.timestamp).formNow()?}}</div> ????????????<div?class="post-author"> ????????????????<a?href="{{?url_for('.user',?username=post.author.username)?}}"> ????????????????????{{?post.author.username?}} ????????????????</a> ????????????</div> ????????????<div?class="post-body">{{?post.body?}}</div> ????????</div> ????</li> ????{%?endfor?%} </ul> {%?endblock?%} 根据提示迅速找到出错的一句代码: <div?class="post-data">{{?moment(post.timestamp).formNow()?}}</div> 发现是fromNow() 拼写错误 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |