Skip to main content

django-social-metadata is a Django application that provides mixin and template to display social metadata for Facebook and Google+.

Installation

Package

javascript-settings can be installed as a normal Python package.

Example instalation for pip:

$ pip install django-social-metadata

Configuration

settings.py

Add javascript-settings to INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'social_metadata',
    ...
)

template

Include template in HEAD section of your main template:

{% include "social_metadata/default_tags.html" %}

Usage Example

views.py

from urlparse import urljoin

from django.conf.settings import MEDIA_URL
from django.views.generic import DetailView

import social_metadata.views

class PhotoSocialDataMixin(social_metadata.views.SocialDataMixin):
    def get_social_title(self):
        return self.title

    def get_social_images(self):
        return [urljoin(MEDIA_URL, self.image.path)]

    def get_social_description(self):
        return self.description

class PhotoDetail(PhotoSocialDataMixin, DetailView):
     model = Photo

Check https://github.com/pozytywnie/django-social-metadata/blob/master/social_metadata/views.py for other social metadata fields.

If you want to use Twitter cards you have to provide all required fields for given type ( https://dev.twitter.com/cards/overview ), as well as submit a link in the validator at https://cards-dev.twitter.com/validator and witelist every type you want to use for given domain.

Metadata

Release files for django-social-metadata 1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-social-metadata 1.3
File Size Uploaded
django-social-metadata-1.3.tar.gz 2.8 kB Details

Release files / django-social-metadata-1.3.tar.gz

Download URL django-social-metadata-1.3.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ba4addfd54c87589c2f7577f618374a9c2594f753805f8a68292f640f68ebf57
BLAKE2b-256 checksum
How to use checksums
e10b7987ca097a14112c4b09000463029a37be195f7cd179a7792e1b873c2837
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.3 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page