Created
May 19, 2011 16:00
-
-
Save joshourisman/981112 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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