View of threads a user has created.

def list_user_threads_view(request, targetUsername):
    ''' View of threads a user has created. '''
    targetUser = get_object_or_404(User, username=targetUsername)
    targetProfile = get_object_or_404(UserProfile, user=targetUser)
    threads = Thread.objects.filter(owner=targetProfile)
    page_name = "{0}'s Threads".format(targetUser.get_full_name())
    create_form = ThreadForm(
        request.POST if "submit_thread_form" in request.POST else None,
        profile=UserProfile.objects.get(user=request.user),
        prefix="create",
        )

    if create_form.is_valid():
        thread = create_form.save()
        return HttpResponseRedirect(reverse("threads:view_thread", kwargs={"pk": thread.pk}))
    elif request.method == "POST":
        messages.add_message(request, messages.ERROR, MESSAGES['THREAD_ERROR'])

    return render_to_response('list_threads.html', {
        'page_name': page_name,
        'threads': threads,
        "create_form": create_form,
        'targetUsername': targetUsername,
        }, context_instance=RequestContext(request))