I have a dictionary in my views.py
file where the values are lists. In my template I have the following html:
{% for key, values in my_dict %}
<tr>
<td colspan="6" class="key">{{ key }}</td>
</tr>
{% for value in values %}
<tr>
<td colspan="6" class="value">{{ value }}</td>
</tr>
{% endfor %}
{% endfor %}
which prints out the name of the key followed by the list items inside the value. However, I want to be able to paginate the keys such that only 10 keys with their values appear per page.
I have the following code to do the pagination inside my index
method in views.py
:
paginator = Paginator(myDict, 10)
page_num = requests.GET.get('page', 1)
page = paginator.page(page_num)
I updated my template to {% for key, values in page %}
and of course I get a TypeError because it's a hashable type. I'm just wondering how I can go about producing the same results as before but without using a dictionary.
I found this answer that suggests using tuples instead of dictionaries, but that doesn't seem to work for me and I'm guessing because my values are lists.