Discuss / Python / 学到这里,整个教程差不多要结束了,最蛋疼的问题...求解答

学到这里,整个教程差不多要结束了,最蛋疼的问题...求解答

Topic source

王新美男

#1 Created at ... [Delete] [Delete and Lock User]

现在点击右上角登陆,登陆成功后,右上角的显示并没有编程user.name,还是注册和登陆(这个对于不会JS和HTML的我来说实在太头疼了)实在是搞不出来,还请说明一下...。

然后日志页面没有点击评论按钮,只有显示当前没有评论一句话(这个我感觉自己研究一下还搞的明白)。

刘勇20449

#2 Created at ... [Delete] [Delete and Lock User]

app.py文件中设置的日志级别:logging.basicConfig(level=logging.INFO) 但是程序启动后,控制台不显示任何信息,自己定位到是orm.py文件中用到元类Model的问题,但是不知道具体该如何解决,不知道你有没有遇到这个问题?

dignitism

#3 Created at ... [Delete] [Delete and Lock User]

是在handlers.py这个文件中。需要改一下返回值。 @get('/blog/{id}') def getblog(id,request): blog=yield from Blog.find(id) comments=yield from Comment.findAll('blogid=?',[id],orderBy='createdat desc') for c in comments: c.htmlcontent=text2html(c.content) print('handlers.py line 82 %s'%request.user) blog.htmlcontent=markdown2.markdown(blog.content) return { '_template':'blog.html', 'blog':blog, '__user':request.__user, 'comments':comments}

response_factory的拦截方法里有一段代码注意看一下

r['__user__'] = request.__user__

asdfl

#5 Created at ... [Delete] [Delete and Lock User]
右上角不显示用户名是因为“Day 8 - 构建前端”的“__base__.html”的源码中用的是“user”,而后面的“response_factory”源码传回的是“__user__”,**教程前后的代码不一致**。把你的“__base__.html”中的“user”替换成“__user__”就行了。

ps:这个评论必须插入到源码段里才能正确显示两个下划线......


  • 1

Reply