Skip to content

Instantly share code, notes, and snippets.

@joshourisman
Created May 19, 2011 16:00
Show Gist options
  • Save joshourisman/981112 to your computer and use it in GitHub Desktop.
Save joshourisman/981112 to your computer and use it in GitHub Desktop.
from django import template
from django.contrib.humanize.templatetags.humanize import intcomma, intword
import facebook
register = template.Library()
@register.simple_tag
def likes(current_site):
graph = facebook.GraphAPI()
object = graph.get_object()
num_likes = int(object["likes"])
if num_likes >= 1000000:
show_likes = intword(num_likes)
else:
show_likes = intcomma(num_likes)
return "%s people" % show_likes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment