Skip to main content

Django app providing view interface to django-secretballot.

Project description

Django Likes

Django app providing view interface to django-secretballot.

This app utilizes django-secretballot to provide Facebook or Google+1 style item liking of Django model objects. Authenticated or anonymous users are allowed to like any given object only once.

Installation

  1. Install or add django-likes to your Python path.

  2. Configure django-secretballot as described here

  3. Add likes to your INSTALLED_APPS setting.

  4. Add likes url include to your project’s urls.py file:

    (r'^likes/', include('likes.urls')),
  5. Add likes.middleware.SecretBallotUserIpUseragentMiddleware to your MIDDLEWARE_CLASSES setting, i.e.:

    MIDDLEWARE_CLASSES = (
        ...other middleware classes...
        "likes.middleware.SecretBallotUserIpUseragentMiddleware",
    )
  6. Add django.core.context_processors.request to your TEMPLATE_CONTEXT_PROCESSORS setting, i.e.:

    TEMPLATE_CONTEXT_PROCESSORS = (
        ...other context processors...
        "django.core.context_processors.request",
    )

Usage

Template Tags

{% like object %}

django-likes provides an inclusion tag called likes which renders a like button for any given object, displaying the number of likes and allowing users to like the object. The tag accepts as first argument the object for which to display and on which to apply likes, i.e.:

{% load likes_inclusion_tags %}

...some html...

{% likes object %}

...some more html...

object here is any Django model object for which django-secretballot voting has been enabled. In the background the like is uniquely addressed to the object using its content type and object id.

The template tag supports AJAX style liking. To enable it you need ensure django-likes’ static media is accessible, see managing static files. You also need to load jQuery somewhere in your template, e.g.:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>

Signals

likes.signals.likes_enabled_test

To determine whether or not liking/voting should be enabled on an object, connect a signal handler to the likes.signals.likes_enabled_test signal, raising a likes.exceptions.LikesNotEnabledException if liking should be disabled. The default behaviour is that liking is enabled for all secretballot enabled objects.

likes.signals.can_vote_test

To determine whether or not the current requesting user can vote, connect a signal handler to the likes.signals.can_vote_test signal, raising a likes.exceptions.CannotVoteException if the current user should not be allowed to vote (the handler receives a request object). The default behaviour is that all users can vote except if they have previously voted on the object in question.

Praekelt Foundation

  • Shaun Sephton

  • Jonathan Bydendyk

  • Hedley Roos

Changelog

1.11

  1. Django 1.11 compatibility.

1.10

  1. Django 1.8 - 1.10 compatibility. Since django-secretballot has deprecated support for Django < 1.8 we follow suit.

0.2

  1. Django 1.6 compatibility.

0.1 (2013-11-08)

  1. Refactor live to on so a jQuery >= 1.9 can be used.

  2. Translations.

0.0.12 (2013-08-16)

  1. Only use jQuery if it is present.

0.0.11 (2013-01-31)

  1. Remove error thrown by middleware when there is no user agent and use alternative to prevent spambot likes. This is a django-secretballot bug.

0.0.10 (2012-10-08)

  1. Added object_liked signal that is sent on like.

0.0.9 (2012-09-28)

  1. Added ability to specify a template to be rendered for likes inclusion tag.

0.0.8 (2012-08-20)

  1. Updated likes_enabled_test and can_vote_test signals to send through sender, thereby allowing listeners to listen to specific senders.

0.0.7 (2012-08-20)

  1. Revert to vote_total on inclusion tag.

0.0.6 (2012-07-24)

  1. Allow for downvotes.

0.0.5 (2011-09-15)

  1. Corrected manifest to include missing static resources.

0.0.4 (2011-09-14)

  1. Documentation, number of fixes.

0.0.3

  1. Handle multiple likes buttons on the same page

  2. Remove dependency on jmbo

  3. Unit tests

0.0.2

  1. Prevent local cache on like redirect.

0.0.1

  1. Initial release.

Project details


Download files

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

Source Distribution

django-likes-1.11.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

django_likes-1.11-py2.7.egg (23.4 kB view details)

Uploaded Source

File details

Details for the file django-likes-1.11.tar.gz.

File metadata

  • Download URL: django-likes-1.11.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-likes-1.11.tar.gz
Algorithm Hash digest
SHA256 c8af5df1380c5fbb6394614c311b8ce9b829098a4be596ef68a77db5a542910a
MD5 a998c57dc02c2652ee2e5cedea449b69
BLAKE2b-256 d94bd75f572f7f4be8b44cee58889606d19bf0716e6e9cc454442d27c22d4112

See more details on using hashes here.

Provenance

File details

Details for the file django_likes-1.11-py2.7.egg.

File metadata

File hashes

Hashes for django_likes-1.11-py2.7.egg
Algorithm Hash digest
SHA256 02ea1e6feb16f7cd8c6ce5e81d8e494934ce397a4fc7b9e5379b9df9b82a8142
MD5 93c045e34de6dd32b20b3de5cc94fb9e
BLAKE2b-256 2d81ac97a6aa8204e85161134a88bb58db6c5923fb13171a1b7ddcadb8d03c38

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page