I'm trying to implement Django's built in pagination feature with a raw 
query set. I've researched the issue and the answer is I need to cast my 
set as a list. Something like this:

paginator = Paginator(refg, 100) # Show 100 contacts per page
paginator._count = len(list(refg))

>From my understanding, setting the count field for the paginator should 
>prevent Django from trying to get the size of my raw set, but this is not the 
>case.  I'm still getting the "RawQuerySet has no len() operation" error.  I've 
>attched the relevant code from my views.py and my template.  

Can I get some advice as to how I can fix this error?


views.py
refg = RefGene.objects.raw(qrefg) 

paginator = Paginator(refg, 100) # Show 100 contacts per page 
paginator._count = len(list(refg)) 

# using django's generated forms 
c = RequestContext(request, { 
    "refg": refg, ... }) 

return HttpResponse(t.render(c)) 


template

{% autopaginate refg %}
{% for r in refg %}

    <tr>
    <td>{{ r.data}}</td>
    <td>{{ r.loc}}</td>
    </tr>

{% endfor %}
{% paginate %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to