0
votes

for detail. I import Solrpy package to use. As for the document on Django project to introduce the pagenator. I pass the pagenator.page (Solrpage) object to tornado template but it doesn't work. I can'd use any method of Solrpage. instead it is rendered as a memory address.

below is the way to use the paginator , which is also the way I use

from django.core.paginator import Paginator, InvalidPage, EmptyPage

def listing(request): contact_list = Contacts.objects.all() paginator = Paginator(contact_list, 25) # Show 25 contacts per page

# Make sure page request is an int. If not, deliver first page.
try:
    page = int(request.GET.get('page', '1'))
except ValueError:
    page = 1

# If page request (9999) is out of range, deliver last page of results.
try:
    contacts = paginator.page(page)
except (EmptyPage, InvalidPage):
    contacts = paginator.page(paginator.num_pages)

return render_to_response('list.html', {"contacts": contacts})

{% for contact in contacts.object_list %} {# Each "contact" is a Contact model object. #} {{ contact.full_name|upper }}
... {% endfor %}

{% if contacts.has_previous %} previous {% endif %} Page {{ contacts.number }} of {{ contacts.paginator.num_pages }}. ....
1
Please reformat your code. Please Edit the question. Please read the formatting instructions on the right side of page.S.Lott

1 Answers

2
votes

Your class definition needs a __str__( self ) method to render as something other than a random address in a template.