Use django paginator

The below are some improvements in the code 

1. Use paginator class for finding next and previous objects