Avoid index error if there aren't pages when iterating for paginator.
Merge pull request #190 from irrelative/master

Fix pagination error on generation