Merge branch 'master' of git@github.com:ericflo/django-pagination
[django-pagination.git] / pagination / middleware.py
1 class PaginationMiddleware(object):
2     """
3     Inserts a variable representing the current page onto the request object if
4     it exists in either **GET** or **POST** portions of the request.
5     """
6     def process_request(self, request):
7         try:
8             request.page = int(request.REQUEST['page'])
9         except (KeyError, ValueError, TypeError):
10             request.page = 1