Skip to content Skip to sidebar Skip to footer

How To Use Cursor() For Pagination?

Can anyone point me to a practical application of cursor() to do pagination? I am not clear how to use cursor() as given in the documentation. This is my query: items =

Solution 1:

Here's a simple example to get you started...

query = db.GqlQuery("SELECT * FROM Item ORDER BY date DESC")
cursor = self.request.get('cursor')
if cursor: query.with_cursor(cursor)
items = query.fetch(30)
cursor = query.cursor()

... your regular output ...

self.response.out.write('<a href="yoururl?cursor=%s">Next Page</a>' % cursor)

Post a Comment for "How To Use Cursor() For Pagination?"