I have a select form in django templates:
<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>
I want to pick the selected file in views.py. I tried request.POST.get() with no success:
if request.method == 'POST':
doc = request.POST.get("name", "")
How can I grab the name of the selected file in python views.py?