ERROR : Exception Value: object of type 'RawStoredProcedureQuerySet' has no len()

Issue #46 wontfix
Anonymous created an issue
def pedidos_view(request,pagina):

    lista_pedidos = VcaOrpe.objects.raw_callproc('[dbo].[WEB_ListadoPedido]',['admin','E'])    
    paginator = Paginator(lista_pedidos,1) # Cuantos productos quieres por pagina? = 3    
        page = int(pagina)
        page = 1

        pedidos = #error
    except (EmptyPage,InvalidPage):
        pedidos =        
    ctx = {'pedidos':lista_pedidos}
    return render_to_response('bmpedido/pedidos.html',ctx,context_instance=RequestContext(request))


TypeError at /pedidos/page/1/
object of type 'RawStoredProcedureQuerySet' has no len()
Request Method: GET
Request URL:    http://localhost/pedidos/page/1/
Django Version: 1.5.1
Exception Type: TypeError
Exception Value:    
object of type 'RawStoredProcedureQuerySet' has no len()
Exception Location: C:\Python27\lib\site-packages\django\core\ in _get_count, line 56
Python Executable:  C:\server\bin\httpd.exe
Python Version: 2.7.6
Python Path:    
Server time:    Fri, 20 Dec 2013 13:56:42 -0500

Comments (3)

  1. Michael Manfre repo owner

    Using RawStoredProcedureQuerySet directly with Paginator doesn't make sense me. At best, it could be changed to behave like a regular list by pulling down the entire resultset, but I don't want to make that an implicit behavior because it defeats any of the potential speed gains of using stored procedures.

    To make your code work with the least amount of effort, evaluate the query to a list before passing it to Paginator.

    Ideally, you would do the paging in the stored procedure, but that will not work with Paginator.

  2. Log in to comment