Reputation: 13
I am new in Django and in stackoverflow and need your help.
I have a list
year=[2020,2019,2018,2017,2016]
grade=[20,90,40,30,69]
category=[fail,distinction,satisfactory,fail,good]
I want to have the following format:
2020 20 fail
2019 90 distinction
2018 40 satisfactory
2017 30 fail
2016 69 good
The format i use is
<table> </table> botstrap
Would be thankful for your help. I am new in html.
Upvotes: 0
Views: 40
Reputation: 52028
You can use zip()
for this:
# view
def some_view(request):
year=[2020,2019,2018,2017,2016]
grade=[20,90,40,30,69]
category=['fail','distinction','satisfactory','fail','good']
context = { 'results': zip(year, grade, category)}
return render(request, 'template.html', context)
# html
{% for year, grade, category in results %}
{{ year }} {{ grade }} {{ category }}
{% endfor %}
Upvotes: 1