现在我们已经拥有一个可以进行用户本地登录的博客系统了。如果有人欣赏你的文章,说不定就会注册成为本地用户,并和你好好交流一番。但头疼的是,用户可能每天都在互联网上浏览很多非常棒的博客,如果每个博客都要去注册才能评论,对用户是个不小的负担。对个人博客这类草根网站,说不定用户就懒得去注册了,你也就损失了一个潜在的”粉丝“。比较流行的解决方案是允许用户通过第三方登录,即可以通过GitHub、微博这类...
老读者注意:上一章消息通知有个bug,即发给管理员的notify必须移动到new_comment.save()的后面,否则会导致action_object存储为NULL,并且导致本章的html拼接锚点失效。原文已更正,为博主的疏忽表示歉意。上一章已经实现了消息通知功能,可以很人性化的把用户引导到被他人回复的页面中去。但是仔细想想,似乎还有不方便的地方:如果页面中评论较多,想找到感兴趣的那一条...
凭借你勤奋的写作,拜读你文章的用户越来越多,他们的评论也分散在众多的文章之中。作为博主,读者的留言肯定是要都看的;而读者给你留言,自然也希望得到回复。怎么将未读的留言呈现给正确的用户呢?总不能用户自己去茫茫文章中寻找吧,那也太蠢了。给评论增加通知功能就是很流行的解决方案:比如微信朋友圈留言的通知、新浪微博留言的通知、以及各种社交平台的“小红点”。本篇将以django-notification...
现在我们的博客已经具有评论功能了。随着文章的评论者越来越多,有的时候评论者之间也需要交流,甚至部分评论还能合并成一个小的整体。因此最好是有某种方法可以将相关的评论聚集到一起,这时候多级评论就非常的有用了。多级评论意味着你需要将模型重新组织为树形结构。“树根”是一级评论,而众多“树叶”则是次级评论。本教程会以第三方库django-mptt为基础,开发多级评论功能。django-mptt模块包含...
本章集中介绍四个重要的小功能:回到顶部浮动按钮、矢量图标、页脚沉底和粘性侧边栏。这几个功能与Django基本没啥关系,更多的是前端知识,但是对博客网站都很重要,问的读者也比较多,因此也集中讲一下好了。回到顶部浮动按钮当用户拜读完你的博文后,可能想回到文章开头重新阅读,或者审视其中的某些内容。如果文章内容较多,不停滑动滚轮回页面顶部未免有点太让人烦躁了。一种解决办法是增加一个回到顶部的浮动按钮...