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 all sent friendship requests
sent = Friend.objects.sent_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 friendshiptags %}
{% 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
Compatibility
This package requires Django 1.4 since v0.9.0. The last release supporting Django 1.3 is v0.8.3.
Project details
Release history Release notifications | RSS feed
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-1.0.0.tar.gz
(14.8 kB
view details)
File details
Details for the file django-friendship-1.0.0.tar.gz.
File metadata
- Download URL: django-friendship-1.0.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8b6493b2dc6212d7f40d45375d8fea367745a29c108f712111e7e328dffd7cc
|
|
| MD5 |
3af49c89f5844c280aa9bac1cbb1e023
|
|
| BLAKE2b-256 |
744b33b84a02f27841a7916ebd193a81985ff1a668a85a7557fb8770044ee069
|