0

我在 django 模板中有一个选择表单:

        <form action="{% url "graph" document.docfile.name %}" method="post" enctype="multipart/form-data">
        {% csrf_token %}
        <select name="{{ document.docfile.name }}" id="{{ document.docfile.name }}" onchange="this.form.submit()">
        <option value=""></option>
        {% for document in documents %}
        <option value="{{ document.docfile.name }}">{{ document.docfile.name }}</option>
        {% endfor %}
        </select>
        </form>

我想在views.py 中选择选定的文件。我试过 request.POST.get() 没有成功:

if request.method == 'POST':
   doc = request.POST.get("name", "")

如何在 python views.py 中获取所选文件的名称?

4

0 回答 0