Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Some Facebook utilities to use in Django projects

Project Description
Django Facebook Utils

**License:** MIT

The intent of this project is to provide some very basic utilities related to Facebook.

At the moment there are only two features:

* An utility that forces the update of an URL in the Facebook's share cache.
* A Context Processor that allows you to hide Facebook [Open Graph Protocol]( <meta> tags from other User Agents.


`pip install django-facebook-utils`


`pip install git+`

How to force an URL to be updated from Facebook's cache

1. The `ping_facebook` command:

`python ping_facebook`

See below **How to extend the ping_facebook command** to fit your needs.

2. Calling the `ping_facebook` shortcut:

from facebook_utils.shortcuts import ping_facebook

if ping_facebook(''):

This shortcut will only return `True` or `False`. If you need more information to debug, you can call `` or use the `ping_facebook` command with `--verbosity=2` (more verbose).

Detecting Facebook requests

1. The `facebookexternalhit` context processor (for templates):

Add `facebook_utils.context_processors.facebookexternalhit` to the [TEMPLATE_CONTEXT_PROCESSOR]( setting in ``:

# .. other stuff

In the template:

{% if facebookexternalhit %}
<meta property="og:title" content="The Rock"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content=""/>
<meta property="og:image" content=""/>
{% endif %}

2. The `is_facebookexternalhit` shortcut:

from facebook_utils.shortcuts import is_facebookexternalhit

def some_view(request):
if is_facebookexternalhit(request):
return HttpResponse('Hello, Facebook!')
return HttpResponse('Hello visitor!')

How to extend the ping_facebook command

You can easily extend the `ping_facebook` command to fit your needs.

1. First of all, [start writing your own custom command](
2. Now extends the `ping_facebook` command:

from import BasePingCommand

3. Finally, extend it to fit your needs:

class Command(BasePingCommand):
help = 'Ping some pages stored in database'

def handle(self, **options):
verbosity = options.get('verbosity')
traceback = options.get('traceback')

for page in Page.objects.all():
page_url = page.get_absolute_url()
self.do_ping(page_url, verbosity, traceback)
Release History

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-facebook-utils-1.0.4.tar.gz (3.5 kB) Copy SHA256 Checksum SHA256 Source Jan 31, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting