I wrote a quick little util method that combines tag clouds from multiple
models into a single cloud.
I'm not sure if other people would find this useful, but I would have liked
to have it included in django-tagging.
def calculate_cloud_from_models(*args):
from tagging.models import Tag
cloud = Tag._default_manager.cloud_for_model(args[0])
for model in args[1:]:
for tag in Tag._default_manager.cloud_for_model(model):
if tag in cloud:
cloud[cloud.index(tag)].count+=tag.count
else:
cloud.append(tag)
return calculate_cloud(cloud)
Original issue reported on code.google.com by phillipm...@gmail.com on 4 Jun 2009 at 8:14
Original issue reported on code.google.com by
phillipm...@gmail.com
on 4 Jun 2009 at 8:14