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

Tag 功能没完成? #55

Closed
xmyangz opened this issue Dec 8, 2017 · 10 comments
Closed

Tag 功能没完成? #55

xmyangz opened this issue Dec 8, 2017 · 10 comments

Comments

@xmyangz
Copy link

xmyangz commented Dec 8, 2017

一旦添加任何 Tag,页面就出错,删光所有 Tag 就正常了。

@liangliangyy
Copy link
Owner

添加Tag会出错? 我这里还真没遇到过,麻烦贴下详细的错误信息哈.

@xmyangz
Copy link
Author

xmyangz commented Dec 8, 2017

Request Method: GET
http://localhost:5000/article/2017/12/7/3.html
1.11.5
ZeroDivisionError
float division by zero
/Users/yangz/Documents/Dev/Python/DjangoBlog/blog/templatetags/blog_tags.py in , line 141
/Users/yangz/anaconda3/bin/python
3.6.3

@liangliangyy
Copy link
Owner

貌似是除0报错,

if tags and len(tags) > 0:
        s = list(map(lambda t: (t, t.get_article_count()), tags))
        count = sum(map(lambda t: t[1], s))
        dd = count / len(tags)
        sidebar_tags = list(map(lambda x: (x[0], x[1], (x[1] / dd) * increment + 10), s))


dd = count / len(tags)
这里报错的吗?
但是我上面是有判断的,
麻烦看看你的代码是不是和我的代码是同步的,另外如果还有错误的话麻烦贴下错误堆栈信息,另外麻烦打印下这里的各个变量看下.

@liangliangyy
Copy link
Owner

大概知道了,可能是dd这个变量是0,也就是count这个变量是0,麻烦你打印下看看是不是这个原因,我晚点修复下,谢谢.

@xmyangz
Copy link
Author

xmyangz commented Dec 8, 2017

是的,我加了一个判断
if dd == 0:
dd = 1
就正常了

@xmyangz
Copy link
Author

xmyangz commented Dec 8, 2017

另外,在微信里命令可以执行,但是文章点击进去就报404,请问还需要配置哪里吗?
还有,希望在便捷登录增加微信和QQ登录,文章增加分享到微信、QQ、微博等功能。如果能全局替换主题就更好了。

@liangliangyy
Copy link
Owner

liangliangyy commented Dec 8, 2017

404的话看看Site.objects.get_current().domain的输出,如果不对的话要配置下site就可以了。
微信的话因为要企业认证,所以微信的相关功能不是很完善。分享功能和QQ登录后续会加上的,敬请期待,
感谢您的支持和关注😁😁

@xmyangz
Copy link
Author

xmyangz commented Dec 9, 2017

是域名不对,微信文章链接、sitemap、RSS 里面都是“example.com",请问可以在 settings 里统一设置域名吗?或者把域名设置成SITE_URL也可以。

@liangliangyy
Copy link
Owner

在后台的站点配置中,将默认站点的修改为你的地址就可以了。

@scholarg
Copy link

我也发现了这个错误

hermanzhaozzzz pushed a commit to hermanzhaozzzz/DjangoBlog that referenced this issue Aug 15, 2021
hermanzhaozzzz pushed a commit to hermanzhaozzzz/DjangoBlog that referenced this issue Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants