Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sjkingo/django_tagcloud
A simple Django templatetag for generating tagclouds
https://github.com/sjkingo/django_tagcloud
django django-application django-tagcloud python python-3 tag-cloud
Last synced: 2 days ago
JSON representation
A simple Django templatetag for generating tagclouds
- Host: GitHub
- URL: https://github.com/sjkingo/django_tagcloud
- Owner: sjkingo
- License: bsd-2-clause
- Created: 2016-01-30T06:32:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-30T07:06:06.000Z (almost 9 years ago)
- Last Synced: 2024-10-12T07:21:49.491Z (about 1 month ago)
- Topics: django, django-application, django-tagcloud, python, python-3, tag-cloud
- Language: Python
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# django_tagcloud
A simple Django templatetag for generating a [tagcloud](https://en.wikipedia.org/wiki/Tag_cloud). It uses a logarithmic algorithm to generate the sizes of each tag.
[![PyPI](https://img.shields.io/pypi/v/django_tagcloud.svg)](https://pypi.python.org/pypi/django_tagcloud)
## 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:
```python
...
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:
```django
{% 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:```django
{% tagcloud tag_list 18 32 %}
```