[Django]-Django pagination with dictionary where key is a list

6๐Ÿ‘

โœ…

I am not sure if it can be count as good answer but anyway: I have just tried to replicate your problem and solution with tuple and it worked. So I think the problem can be in your code. My test code:

>>> from django.core.paginator import Paginator
>>> d = {'a': [1,2], 'b': [3,4]}
>>> p = Paginator(d, 1)
>>> p1 = p.page(1)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: unhashable type
>>> t = tuple(d.items())
>>> t
(('a', [1, 2]), ('b', [3, 4]))
>>> p = Paginator(t, 1)
>>> p.page(1).object_list
(('a', [1, 2]),)
>>> p.page(2).object_list
(('b', [3, 4]),)

UPDATE: and looping also works. So can you show what structures do you have?

๐Ÿ‘คbellum

Leave a comment