How to get a certain value from a dictionary in a django template?

Hello.
The template is passed a dictionary like:
{'1A': ['Name', 'State', 'Name2', 'State2']}
{'2A': ['Name', 'State', 'Name2', 'State2', 'Name3', 'State3', ...]}
In the template table that needs to be filled so:

 <input type="hidden" name="stud" value="{{ Name }}">
 {{ Name }}
 <input type="hidden" name="state" value class="state">
 {{ State }}
 

Fully table:
{% for school_class, data in students_data.items %}
 <div id="{{ school_class }}" class="tab-pane fade">
 <form method="post" action class="data">
 {% csrf_token %}

 {% for student in data %}

 {% endfor %}
 <table class="table sch_{{ school_class }}">
<thead>
 <input type="hidden" name="school" value="{{ school_class }}">
 the <tr><th colspan="2">{{ school_class }}</th>
</tr></thead>
<tbody><tr>
 <input type="hidden" name="stud" value="{{ student }}">
 <td>{{ student }}</td>
 <input type="hidden" name="state" value class="state">
 <td id="editable">{{ student }}</td>
</tr></tbody>
</table>
 <div class="col-md-12" style="text-align: right;">
 <button type="submit" class="btn btn-success" id="send">Save</button>
</div>
</form>
</div>
 {% endfor %}

Ka correctly to get the values? In this cycle of getting on each iteration, filling the table with identical values, respectively.
Thank you to everyone who responds)

UPD
Parsed Excel in a dictionary. The classroom, the students in the class and the availability of the student. The number of students may be different. Here's the code view, you realize that here it is necessary to correct
files = DataFile.objects.values_list('file')
 for file in files:
 date, data = parse_table(media_root + '/' + file[0])
 if date == time.strftime('%d.%m.%Y'):
full_dict.update(data.items())
 context['date'] = date
 context['class_names'] = full_dict.keys()
 context['students_data'] = full_dict
June 14th 19 at 19:14
1 answer
June 14th 19 at 19:16
Solution
To find out how to get the values, you must first find out why they generally come in such an inconvenient form, and if possible to learn and correct no - transform in a more convenient form, for example in nested lists:
def table_view(request):
 data = {'2A':
 ['Name', 'State',
 'Name2', 'State2',
 'Name3', 'State3',
 'Name4', 'State4',
 'Name5', 'State5']
}
 data['2A'] = [data['2A'][i:i+2] for i in range(0, len(data['2A']), 2)]
 return render(request, 'app/template.html', {'students_data': data})


And then in the template:
{% for student in data %}

 <input type="hidden" name="stud" value="{{ student.0 }}">
 {{student.0 }}
 <input type="hidden" name="state" value class="state">
 {{ student.1 }}

{% endfor %}

or as a variant - to use a namedtuple, but there speed will not know.
thanks for the reply. I updated the question. - helene.Goldner commented on June 14th 19 at 19:19
What format come the data after parsing the table? What in data? - alexandro_Auer commented on June 14th 19 at 19:22
{'1A': ['Ivanov', 'Missing', 'Smith', 'Present'], '1B': ['Vasechkin', 'is Missing', 'Cats', 'Are', 'racin', 'is Missing', 'Schukin', 'Present', 'Mukhin', 'Missing'] ...} - helene.Goldner commented on June 14th 19 at 19:25
Here you need to function parse_table to understand or to do like I wrote in response, well, of course slightly tweak the below classes are not hardcoding. - alexandro_Auer commented on June 14th 19 at 19:28
thanks for the advice). I will pick the parser - helene.Goldner commented on June 14th 19 at 19:31
If there is no knowledge to pick the parser no sense, it is easier to convert, especially not for such a resource-intensive process. - alexandro_Auer commented on June 14th 19 at 19:34
thanks for the tip with the attached list. Corrected the parser:
with
data[class_name] += [row[0].value, row[1].value]
on
data[class_name] += [[row[0].value, row[1].value]]
and it works! - helene.Goldner commented on June 14th 19 at 19:37

Find more questions by tags Django