@login_required
def unfollow(request, username, template_name='relationships/relationship_delete_confirm.html', success_template_name='relationships/relationship_delete_success.html', content_type='text/html'):
 to_user = get_object_or_404(User, username=username)
 from_user = request.user
 next = request.GET.get('next', None)
 if (request.method == 'POST'):
  relationship = get_object_or_404(Relationship, to_user=to_user, from_user=from_user)
  relationship.delete()
  if request.is_ajax():
   response = {'success': 'Success', 'to_user': {'username': to_user.username, 'user_id': to_user.pk}, 'from_user': {'username': from_user.username, 'user_id': from_user.pk}}
   return HttpResponse(json.dumps(response), content_type='application/json')
  if next:
   return HttpResponseRedirect(next)
  template_name = success_template_name
 context = {'to_user': to_user, 'next': next}
 return render_to_response(template_name, context, context_instance=RequestContext(request), content_type=content_type)

@ login_required def unfollow ( request , username , template_name = 'relationships/relationship_delete_confirm.html' , success_template_name = 'relationships/relationship_delete_success.html' , content_type = 'text/html' ) : to_user = get_object_or_404 ( User , username = username ) from_user = request . user next = request . GET . get ( 'next' , None ) if ( request . method == 'POST' ) : relationship = get_object_or_404 ( Relationship , to_user = to_user , from_user = from_user ) relationship . delete ( ) if request . is_ajax ( ) : response = { 'success' : 'Success' , 'to_user' : { 'username' : to_user . username , 'user_id' : to_user . pk } , 'from_user' : { 'username' : from_user . username , 'user_id' : from_user . pk } } return HttpResponse ( json . dumps ( response ) , content_type = 'application/json' ) if next : return HttpResponseRedirect ( next ) template_name = success_template_name context = { 'to_user' : to_user , 'next' : next } return render_to_response ( template_name , context , context_instance = RequestContext ( request ) , content_type = content_type )
removes a "follow" relationship .