Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: ef5149c7a3
Fetching contributors…

Cannot retrieve contributors at this time

96 lines (55 sloc) 2.29 KB

django-simple-friends adds friendship management to your project.

Flattr Button


  • Manages relationships between registered users only.
  • Two phase friending.
  • Blocking.


  1. Add "django-simple-friends" directory to your Python path.
  2. Add "friends" to your INSTALLED_APPS tuple found in your settings file.
  3. Run syncdb to create tables and seed friendship data for existing users.
  4. Include "friends.urls" to your URLconf. (optional)

Testing & Example

You can use the project in the example directory in repository to run tests:

python example/ test friends

Note that if you have installed django-simple-friends as a package you are likely to have a project already, in this case you can just run the test command of your projects. Example project is intended for developers.


Usage examples.

First, we're going to get two different users for our examples:

user1 = User.objects.get(id=1)
user2 = User.objects.get(id=2)

Friend request

user1 requests friendship to user2:

FriendshipRequest.objects.create(from_user=user1, to_user=user2, message='Friends?')

Accepting friendship request

user2 accepts user1 request:

fr = FriendshipRequest.objects.get(from_user=user1, to_user=user2, accepted=False)

Declining friendship request

user2 declines user1 request:

fr = FriendshipRequest.objects.get(from_user=user1, to_user=user2, accepted=False)

Are we friends?

If users are friends then return True:

Friendship.objects.are_friends(user1, user2):

Getting all friends of a user

friends will be a list with all id's from user1 friends:

friends = Friendship.objects.friends_of(user1).values_list('id', flat=True)

See Also

Jump to Line
Something went wrong with that request. Please try again.