Python view**.views.upload_文件没有';t返回HttpResponse对象。它没有返回任何结果

Python view**.views.upload_文件没有';t返回HttpResponse对象。它没有返回任何结果,python,django-views,Python,Django Views,我有两种方法: def handle_uploaded_file(file): with open(file) as csvfile: sample = csv.reader(csvfile, dialect='excel') return sample def upload_file(request): if request.method == 'POST': form = UploadFileForm(request.POST

我有两种方法:

def handle_uploaded_file(file):
    with open(file) as csvfile:
        sample = csv.reader(csvfile, dialect='excel')
        return sample

def upload_file(request):
    if request.method == 'POST':
        form = UploadFileForm(request.POST, request.FILES)
        if form.is_valid():
            result=handle_uploaded_file(request.FILES['file'])
            return render('show_imported.html',{'list': result})
    else:
        form = UploadFileForm()
        return render_to_response('upload.html', {'form':form},context_instance=RequestContext(request))
以下是我的看法:

upload.html:

{%extends'layout.html%} {%load staticfiles%}

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="{% static 'Mebadas/themes/style.css' %}" />
    <title></title>
</head>
<body>
{% block content %}
<form method="POST" action="">
    <table>
        {{ form.as_table }}
    </table>

    {% csrf_token %}
<input type="submit" value="Submit">
</form>
{% endblock content %}
</body>
</html>

{%block content%}
{{form.as_table}}
{%csrf_令牌%}
{%endblock内容%}
和show_imported.html

{% extends 'layout.html' %}
{% load render_table from django_tables2 %}
{% load staticfiles %}

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="{% static 'Mebadas/themes/paleblue/css/screen.css' %}" />
    <title></title>
</head>
<body>
{% render_table list %}
</body>
</html>
{%extends'layout.html%}
{%load render_Tables from django_Tables 2%}
{%load staticfiles%}
{%render_表列表%}
当运行upload_文件时,它返回

/upload/处的值错误查看Mebadas.views.upload\u文件未被删除 返回一个HttpResponse对象。它没有返回任何结果


我做错了什么?

如果您的方法是POST,并且表单无效,则不会返回任何响应

i、 e如果
form.is\u valid()
返回False,则没有其他块