Skip to main content

Provides tempatetags for ‘Tweet This’ and ‘Share this on Facebook’.

A fork of django-social-share by Flavio Curella.

Installation

$ pip install django-shareable

Add the app to INSTALLED_APPS:

INSTALLED_APPS += ['django_shareable']

It’s recommended to add django.core.context_processors.request to your `` TEMPLATE_CONTEXT_PROCESSORS`` list. This way the templatetags will use the correct scheme and hostname.

If django.core.context_processors.request is not present, it will simply concatenate the current site’s domain (from django.contrib.sites) and the object’s relative URL together.

Usage

{% post_to_facebook <object_or_url> <link_text> %}

{% post_to_twitter <text_to_post> <object_or_url> <link_text> %}

<text_to_post> may contain any valid Django Template code. Note that Facebook does not support this anymore.

<object_or_url> is optional. If you pass a django model instance, it will use its get_absolute_url method. Additionally, if you have django_bitly installed, it will use its shortUrl on Twitter.

<link_text> is also optional. It defines the text used for the a element. Defaults to ‘Post to Facebook’ and ‘Post to Twitter’

{% post_to_twitter_url <text_to_post> <object_or_url> %}

Will add a tweet_url variable to the context, containing the URL for the Twitter sharer popup.

{% post_to_facebook_url <object_or_url> %}

Will add a facebook_url variable to the context, containing the URL for the Facebook sharer popup.

Example:

{% load social_share %}

{% post_to_facebook object_or_url "Post to Facebook!" %}
{% post_to_twitter "New Song: {{object.title}}. Check it out!" object_or_url "Post to Twitter" %}

Templates are in django_shareable/templatetags/post_to_twitter.html and django_shareable/templatetags/post_to_facebook.html. You can override them to suit your mileage.

Metadata

Release files for django-shareable 0.2.7

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-shareable 0.2.7
File Size Uploaded
django-shareable-0.2.7.tar.gz 5.2 kB Details

Release files / django-shareable-0.2.7.tar.gz

Download URL django-shareable-0.2.7.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
85cf960e012700e46ae23726f3e1f728a566fda8fcdef1a216322bb4e2b99e9e
BLAKE2b-256 checksum
How to use checksums
626cacf1bc00f0a6fee5cba24159a83a4c2ae216e9479c2688e37d43115d9683
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.7 This release

1 release file

0.2.6

1 release file

0.2.5

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