django_tagcloud

A simple Django templatetag for generating tagclouds


Keywords
django, django-application, django-tagcloud, python, python-3, tag-cloud
License
BSD-3-Clause
Install
pip install django_tagcloud==0.1.1

Documentation

django_tagcloud

A simple Django templatetag for generating a tagcloud. It uses a logarithmic algorithm to generate the sizes of each tag.

PyPI

How to use

Installation and usage is simple:

  1. $ pip install django_tagcloud

  2. Add tagcloud to your INSTALLED_APPS

  3. In your view code, assemble a list of (tag, weight) tuples and add it to the response context, for instance:

    ...
    tag_list = [('apple', 3), ('orange', 9), ('pear', 4), ('plum', 12)]
    return render(request, template, {'tag_list': tag_list})
  4. In a template, simply call the templatetag:

    {% load tagcloud %}
    
    {% tagcloud tag_list %}

Customisation

Currently the only customisation possible is specifying the minimum and maximum font sizes that the templatetag will use. By default these are 12px and 38px. You can change this by passing one (or both) as arguments to the templatetag:

{% tagcloud tag_list 18 32 %}