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 Friend, Follow

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

    # List all unread friendship requests
    requests = Friend.objects.unread_requests(user=request.user)

    # List all rejected friendship requests
    rejects = Friend.objects.rejected_requests(user=request.user)

    # 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 = Friend.objects.add_friend(request.user, other_user)
    Friend.objects.are_friends(request.user, other_user) == True
    Friend.objects.remove_friend(other_user, request.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.1.tar.gz (12.2 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-friendship-0.8.1.tar.gz
Algorithm Hash digest
SHA256 9dcd181772868111597ba2ce838f42d416f521b54dc6c98071ac084f6ede683e
MD5 e37fe756eefef6f7368692c4bac7ea18
BLAKE2b-256 4ccba8f176e031aa5367c8c87c08b42e20f5ebb8d068e64c82650d6a6607e53d

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