Package Reference¶
Views¶
Class Based Views¶
All the views are implemented as classes but view functions are also provided.
-
class
friends.views.BaseActionView(**kwargs)¶ Base class for action views.
-
set_url(request, **kwargs)¶ Set the
urlattribute so that it can be used whenget_redirect_url()is called.urlis determined using the following methods, in order:- It can be set in the urlconf using
redirect_tokeyword argument. - If
redirect_to_paramkeyword argument is set in urlconf, the request parameter with that name will be used. In this case the request parameter must be provided in runtime. - If the request has
redirect_toto parameter is present, its value will be used. - If
REDIRECT_FALLBACK_TO_PROFILEsetting isTrue, current user’s profile URL will be used. HTTP_REFERERheader’s value will be used if exists.- If all else fail,
'/'will be used.
- It can be set in the urlconf using
-
-
class
friends.views.FriendshipAcceptView(**kwargs)¶
-
class
friends.views.UserBlockView(**kwargs)¶
-
class
friends.views.FriendshipCancelView(**kwargs)¶
-
class
friends.views.FriendshipDeclineView(**kwargs)¶
-
class
friends.views.FriendshipDeleteView(**kwargs)¶
-
class
friends.views.FriendshipRequestView(**kwargs)¶
-
class
friends.views.UserUnblockView(**kwargs)¶
View Functions¶
Tip
If you want to customize the views provided, check out Class Based Views first.
-
friends.views.friendship_request(request, *args, **kwargs)¶
-
friends.views.friendship_accept(request, *args, **kwargs)¶
-
friends.views.friendship_decline(request, *args, **kwargs)¶
-
friends.views.friendship_cancel(request, *args, **kwargs)¶
-
friends.views.friendship_delete(request, *args, **kwargs)¶
-
friends.views.user_block(request, *args, **kwargs)¶
-
friends.views.user_unblock(request, *args, **kwargs)¶
Models¶
-
class
friends.models.FriendshipRequest(*args, **kwargs)¶ An intent to create a friendship between two users.
See also
There should never be complementary
FriendshipRequest‘s, as inuser1requests to be friends withuser2whenuser2has been requested to be friends withuser1. See howFriendshipRequestViewchecks the existence of aFriendshipRequestfromto_usertofrom_user.-
accept()¶ Create the
Friendshipbetweenfrom_userandto_userand mark this instance as accepted.friendship_acceptedis signalled on success.See also
-
cancel()¶ Deletes this
FriendshipRequestfriendship_cancelledis signalled on success.See also
-
decline()¶ Deletes this
FriendshipRequestfriendship_declinedis signalled on success.See also
-
-
class
friends.models.FriendshipManager¶ -
are_friends(user1, user2)¶ Indicate if
user1anduser2are friends.Parameters: Return type: bool
-
befriend(user1, user2)¶ Establish friendship between
user1anduser2.Important
Instead of calling this method directly,
FriendshipRequest.accept(), which calls this method, should be used.Parameters:
-
-
class
friends.models.Friendship(*args, **kwargs)¶ Represents the network of friendships.
-
friend_count()¶ Return the count of
friends. This method is used inFriendshipAdmin.Return type: int
-
Signals¶
friendship_accepted¶
-
friends.signals.friendship_accepted¶ Sent when a
FriendshipRequestis accepted.Arguments sent with this signal:
senderFriendshipRequestinstance that is accepted.
friendship_declined¶
-
friends.signals.friendship_declined¶ Sent when a
FriendshipRequestis declined byto_user.Arguments sent with this signal:
senderFriendshipRequestinstance that is declined.
friendship_cancelled¶
-
friends.signals.friendship_cancelled¶ Sent when a
FriendshipRequestis cancelled byfrom_user.Arguments sent with this signal:
senderFriendshipRequestinstance that is cancelled.
Signal Handlers¶
-
signals.create_friendship_instance(sender, instance, created, raw, **kwargs)¶ Create a
FriendshipRequestfor newly createdUser.See also
post_savebuilt-in signal.
-
signals.create_userblocks_instance(sender, instance, created, raw, **kwargs)¶ Create a
UserBlocksfor newly createdUser.See also
post_savebuilt-in signal.