问题
I'm having trouble using djangoś paginator function. In this question i can't find the solution: Django: Paginator + raw SQL query
With Table.object.all()
i have no trouble, but with raw sql i receive the error object of type 'RawQuerySet' has no len()
I tried also
num = len(list(ads)) paginator = Paginator(num, 2)
and i receive object of type 'int' has no len()
. I tried to print num and it contains the correct number so i don't understand why paginator doesn't like it. Hope someone can help.
回答1:
Found the solution here: http://groups.google.com/group/django-users/browse_thread/thread/42cf7b5a88f31b9c
that means:
paginator = Paginator((list(ads)), 10)
来源:https://stackoverflow.com/questions/10214030/django-paginator-and-raw-sql