Django实现标签云

发布时间:2019-09-26 12:00--阅读:715--评论:1条

1、在templatetags下的blog_tags.py

@register.simple_tag
def get_tags():
    return Tag.objects.all()
2、模板上调用right_side_bar.html

{% load blog_tags %}
<div class="row">
    <div class="widget" >
        <h3>标签云:</h3>
        {% get_tags as tag_list %}
        {% for tag in tag_list %}
                <a href="{% url 'blog:blog_tag' tag.id %}" style="font-size: 20px;">
                    <span style="padding: 5px;" class="label {% cycle 'label-default' 'label-primary' 'label-success' 'label-info' 'label-warning' 'label-danger' %}">{{ tag.name }}</span>
                </a>&nbsp;
        {% endfor %}
    </div>
</div>
3、效果

Django连接mariadb数据库

微信公众号ID(feiutech)

微信公众号ID:feiutech

评论列表

187楼:The anti estrogen action of Kebirzol is preferred by athletes and bodybuilders for use during a steroid cycle to reduce bloating due to excess water retention and prevent the formation of gynecomastia related breast tissue that is a side effect of some anabolic steroids <a href=http://buylasixon.com/>lasix prescription</a>

Mumethelm 于2022-10-10 00:46

共1条评论

我要评论

用户名:
邮箱: