To use flickr as an example, a request URL looks something like this:
'http://api.flickr.com/services/rest/?&method=flickr.people.getPublicPhotos&api_key=' + settings.FLICKR_API_KEY + '&user_id=' + userid + '&format=json&per_page' + per_page + '&page=' + page + '&nojsoncallback=1'
where page controls which page to display and per_page controls the number of photos to return
To simplify matters, let’s make per_page fixed. So my question is, how can I implement a paging system that allows a user to go one page forwards or back at anytime on the webpage?
I imagine I would need to pass the page number to iterate through the request URL such that the right data is displayed. SO I guess I’m not sure how to tie the template to the views.py. Essentially, I’m looking for the Django version of this Rails question.
The examples and plugins I have come across so far (e.g. django-pagination) mainly deal with pagination resulting from a database query.
Django-pagination will work with any list of objects — not just calls from the database. The example here actually starts off with an example that has nothing to do with local models or databases.
For an API-type call, you’d just need to read your objects into a list, and then create a new Paginator objects based off of that list. All you have to do is give it the number of objects you want per page. It’s really very simple.