def METHOD_NAME(request):
    tm = get_object_or_404(
        TeamMembership, user=request.user, team__contest=request.contest
    )
    tm.delete()
    return HttpResponseRedirect(
        reverse('team_view', kwargs={'contest_id': request.contest.id})
    )