You could do this on a GET or a POST. Here's the view it on a GET since that's simpler.

from django.http import JsonResponse def follow_user(request, user_profile_id): profile_to_follow = get_object_or_404(UserProfile, pk=user_profile_id) user_profile = request.user.userprofile data = {} if profile_to_follow.follows.filter(id=user_profile.id).exists(): data['message'] = "You are already following this user." else: profile_to_follow.follows.add(user_profile) data['message'] = "You are now following {}".format(profile_to_follow) return JsonResponse(data, safe=False)

Then in your urls.py you'd need to add the following to your urlpatterns.

url(r'^follow/(?<user_profile_id>[\d]+)/$', views.follow_user)

Then you'd need to use some javascript like the following:

$('.follow-button').click(function() { $.get($(this).data('url'), function(response) { $('.message-section').text(response.message).show(); }); });

This assumes some html like the following: