Skip to main content

django-friendship provides an easy extensible interface for following and friendship

Project description

django-friendship

Usage

Add friendship to INSTALLED_APPS and run syncdb.

To use django-friendship in your views:

from django.contrib.auth.models import User
from friendship.models import Friendship, Following

def my_view(request):
    # List of this user's friends
    all_friends = Friendship.objects.friends(request.user)

    # List all unread friendship requests
    requests = Friendship.objects.requests(user=request.user, unread=True)

    # List all rejected friendship requests
    rejects = Friendship.objects.requests(user=request.user, rejected=True)

    # List of this user's followers
    all_followers = Following.objects.followers(request.user)

    # List of who this user is following
    following = Following.objects.following(request.user)

    ### Managing friendship relationships
    other_user = User.objects.get(pk=1)
    new_relationship = Friendship.objects.add_friend(request.user, other_user)

    # Create request.user follows other_user relationship
    following_created = Following.objects.add_follower(request.user, other_user)

To use django-friendship in your templates:

{% load friendship %}

{% friends request.user %}
{% followers request.user %}
{% following request.user %}
{% friend_requests request.user %}

Signals

django-friendship emits the following signals:

  • friendship_request_created

  • friendship_request_rejected

  • friendship_request_canceled

  • friendship_request_accepted

  • friendship_removed

  • follower_created

  • following_created

  • follower_removed

  • following_removed

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-friendship-0.8.0.tar.gz (12.1 kB view details)

Uploaded Source

File details

Details for the file django-friendship-0.8.0.tar.gz.

File metadata

File hashes

Hashes for django-friendship-0.8.0.tar.gz
Algorithm Hash digest
SHA256 68610c77c34216a9c9bac7b1c7c47d0c1c8d2c94dff8118327b759d5ba85b499
MD5 69a9c987f5fad4dd2181691a89c3d08b
BLAKE2b-256 b7bef2ee675b0aee197e61a7379c7beccd8dfb786739665700a268e8f20f1450

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