Django OpenGraph

OpenGraph App for Django >= 1.4

OpenGraph App for Django >= 1.4

Adds HTML Meta tags for OpenGraph support.

Installation

pip install -e git+git://github.com/leveille/django-opengraph.git#egg=opengraph

Upgrade

pip install -U -e git+git://github.com/leveille/django-opengraph.git#egg=opengraph

Usage

Optional Configuration

  1. Add opengraph to your settings.py INSTALLED_APPS list
  2. There are a few configuration options to opengraph that can be placed in an OPTIONAL dictionary called OPENGRAPH_CONFIG in settings.py.
OPENGRAPH_CONFIG = {
    'FB_ADMINS': '###',
    'FB_APP_ID': '###',
    'DEFAULT_IMAGE': '%sdefault/image.png' % STATIC_URL,
    'SITE_NAME': 'Your Site Name',
}

Loading Template Tags

  1. Load the opengraph_tags custom tags
  2. Call the opengraph tag, passing in the appropriate parameters

Assume the following configuration:

OPENGRAPH_CONFIG = {
    'FB_ADMINS': '123',
    'FB_APP_ID': '456',
    'DEFAULT_IMAGE': '%sdefault/image.png' % STATIC_URL,
    'SITE_NAME': 'Your Site Name',
}
{% load opengraph_tags %}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Django OpenGraph Example</title>
        {% opengraph title='Django OpenGraph Example' description='This is a test' image="http://site.tld/image.png" %}
    </head>
    <body></body>
</html>

The result, including the use of the OPENGRAPH_CONFIG options defined above, would be:

<meta property="fb:admins" content="123">
<meta property="fb:app_id" content="456">
<meta property="og:title" content="Django OpenGraph Example">
<meta property="og:type" content="website">
<meta property="og:url" content="http://127.0.0.1:8000/">
<meta property="og:image" content="http://site.tld/image.png">
<meta property="og:description" content="This is a test">
<meta property="og:site_name" content="Your Site Name">

OpenGraph Tag

{% opengraph fb_admins="" fb_app_id="" site_name="" type="" url="" title="" description="" image="" %}