Created
April 29, 2011 13:43
-
-
Save joshourisman/948312 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.contenttypes.models import ContentType | |
from django.contrib.humanize.templatetags.humanize import intcomma, intword | |
from whereabouts.models import SocialNetworkProfile | |
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