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

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-0.0.4.tar.gz (7.5 kB view details)

Uploaded Source

Built Distributions

django_likes-0.0.4-py2.7.egg (13.5 kB view details)

Uploaded Source

django_likes-0.0.4-py2.6.egg (13.5 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-likes-0.0.4.tar.gz
Algorithm Hash digest
SHA256 9b0eaa6670556a91d093d09ca2acf95752a8f553c16a9b7defa972f9d47df0d9
MD5 5e454c9c85b474be6644ac36de410ea2
BLAKE2b-256 848292022d09e554af8d57b649305e4231ffb01cbf4f8a45816374504972da58

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for django_likes-0.0.4-py2.7.egg
Algorithm Hash digest
SHA256 52ee33bcb6be6c568aeb33ad72abd04dd6930678816e3ca9938d87c657b9360d
MD5 192aca6b8efd8a23483d7eb3f80cff25
BLAKE2b-256 b76ac240b803f97163e1286c9616e424873ec57949ed89bfbd945628c0f910a5

See more details on using hashes here.

Provenance

File details

Details for the file django_likes-0.0.4-py2.6.egg.

File metadata

File hashes

Hashes for django_likes-0.0.4-py2.6.egg
Algorithm Hash digest
SHA256 74fe42d1398e9ea92110df5e4839401626ae5a9e0972f79e4bb442461c1bddd3
MD5 4b1f1db6ecd67a7ed8bf98f93c4c7ed9
BLAKE2b-256 eb045fab9199a982f5899f73e06b4be81af2ee2cc0a79e7391b7a3f9b50a4161

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