Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Application which enables following features for users. Can be used for contact books or whatnot

Project description

django-follow
=============

django-follow enables your users to follow any model in your Django
application.

Installation:
-------------

::

pip install django-follow

Usage:
------

- Add ``follow`` to your ``INSTALLED_APPS``
- Include ``follow.urls`` into your URLs if you plan on using the
views:

::

urlpatterns = patterns('',
url('^', include('follow.urls')),
)

- Register the models you want to be able to follow in your
``models.py`` files:

::

from django.db import models
from follow import utils

class MyModel(models.Model):
field = models.CharField(max_length = 255)


utils.register(MyModel)

Test
----

The repository includes a sample project and application that is
configured to test ``django-follow``.

Clone the repository and cd into the project folder:

::

cd test_project/
python manage.py test follow

API
---

Manager
~~~~~~~

- ``FollowManager.create(user, obj, **kwargs)``:
Makes ``user`` follow ``obj``

- ``FollowManager.get_or_create(user, obj, **kwargs)``:
Returns a tuple ``(Follow, bool)``

- ``FollowManager.is_following(user, obj)``:
Returns ``bool``

- ``FollowManager.get_follows(model_or_object)``:
Returns all the ``Follow`` objects associated with a certain model
or object.

Utils
~~~~~

- ``follow.utils.register(model, field_name, related_name, lookup_method_name)``:
Registers ``model`` to django-follow.

- ``follow.utils.follow(user, object)``:
Makes ``user`` follow ``object``

- ``follow.utils.unfollow(user, object)``:
Makes ``user`` unfollow ``object``

- ``follow.utils.follow_url(user, object)``:
Returns the right follow/unfollow URL for ``user`` and ``object``

- ``follow.utils.follow_link(object)``:
Returns the following URL for ``object``

- ``follow.utils.unfollow_link(object)``:
Returns the unfollowing URL for ``object``

Template Tags
~~~~~~~~~~~~~

django-follow ships a template tag that creates urls and one filter to
check if a user follows an object:

::

{% load follow_tags %}
{% follow_url object %}
{% request.user|is_following:object %}

- ``{% follow_url object %}``:
Returns the URL to either follow or unfollow the object, depending
on whether ``request.user`` is already following the object.

- ``{% follow_url object other_user %}``:
Same as above - but instead of resolving for ``request.user`` it
resolves for any user you pass in.

- ``{% request.user|is_following:object %}``:
Returns ``True``/``False`` if the user follows / does not follow the
object.

Signals
~~~~~~~

django-follow provides two signals:

- ``follow.signals.followed(sender, user, target, instance)``
- ``follow.signals.unfollowed(sender, user, target, instance)``

Release Notes
-------------

v0.4 - *BACKWARDS INCOMPATIBLE*

- Made the manager *a lot* lighter.
- Removed ``Model.followers`` method
- Added ``Model.get_follows`` method returning all the ``Follow``
objects
- Moved ``Follow.follower`` to ``Follow.user``
- Replaced ``Follow.get_object`` method with read/writable
``Follow.target`` property
- ``follow.util`` moved to ``follow.utils``
- No more M2M following

--------------

`@flashingpumpkin <http://twitter.com/flashingpumpkin>`_

Project details


Release history Release notifications

History Node

0.6.1

History Node

0.6

History Node

0.5.5

History Node

0.5.4

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.6

History Node

0.4.5

History Node

0.4.4

History Node

0.4.3

This version
History Node

0.4.2

History Node

0.3

History Node

0.2

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django-follow-0.4.2.tar.gz (7.8 kB) Copy SHA256 hash SHA256 Source None Jul 22, 2011

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page