def add(request, username): friend = get_object_or_404(User, username = username) me(request).add_friend(friend) if request.is_ajax(): return HttpResponse("True") else: return HttpResponseRedirect("/friends")
def cancel(request, username): friend = get_object_or_404(User, username = username) friendship = get_object_or_404(Friendship, from_friend = friend, to_friend = request.user) me(request).cancel_friendship_request(friendship) if request.is_ajax(): return HttpResponse("True") else: return HttpResponseRedirect("/friends")