开发者

Error when using Tag Cloud in Django

开发者 https://www.devze.com 2022-12-13 04:19 出处:网络
There are my code: {% load tag_cloud %} {% tag_cloud_for_model blog.Entry as tags with steps=6 min_count=1 distribution=log %}

There are my code:

{% load tag_cloud %}
{% tag_cloud_for_model blog.Entry as tags with steps=6 min_count=1 distribution=log %}
{% for tag in tags %}
    <span class="tag-{{tag.font_size|add:"1"}}"><a href="/blog/tag/{{tag.name|slugify}}/">{{tag.name}}</a></span> 
{% endfor %}

Everything loo开发者_开发知识库ks normal until I have 6 tag "django" in 6 different entries. The error is raised as follows:

TemplateSyntaxError at /blog/tags/
...
Caught an exception while rendering: invalid literal for int():
...
ValueError: invalid literal for int():


Not knowing anything about the tagging Module that you mention, I can only guess that the problem is on the {{tag.font_size|add:"1"}} call. I think the value of one of your tag.font_size is not numerical... Is it possible that some of the values is None or a non-digit character?

One way to find out is to remove momentarily the |add:"1" and look at the generated HTML to see what is being rendered...

0

精彩评论

暂无评论...
验证码 换一张
取 消