Solved errors: object of type ‘RawQuerySet’ has no len()

Do you get this error object of type 'RawQuerySet' has no len() with Django? In this tutorial I will explain how to easily solve this error.

I'm getting this error when I trying to use the Django's Paginator with a raw sql query.

Now my code is


products = Products.objects.raw("SELECT * FROM app_products")
paginator = Paginator(products, 15)

To solve, the error, I will add list() at products:

paginator = Paginator(list(products), 15)

In this way I have solved the error!









Leave a Comment