          request = self.req.get('/paginator/?page=%d' % (num_pages + 1,))
          response = MockPaginatorView.as_view()(request)
          content = json.loads(response.content)
          self.assertEqual(response.status_code, status.NOT_FOUND)
 
</s> remove         url = "%s?page=%d" % (self.request.path, page_number)
 </s> add         url = URLObject.parse(self.request.get_full_path())
        url = url.add_query_param('page', page_number) </s> remove             url = "%s&limit=%d" % (url, limit)
 </s> add             url = url.add_query_param('limit', limit)
    def test_existing_query_parameters_are_preserved(self):
        """ Tests that existing query parameters are preserved when
        generating next/previous page links """
        request = self.req.get('/paginator/?foo=bar&another=something')
        response = MockPaginatorView.as_view()(request)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.OK)
        self.assertTrue('foo=bar' in content['next'])
        self.assertTrue('another=something' in content['next'])
        self.assertTrue('page=2' in content['next'])
          request = self.req.get('/paginator/?page=%d' % (num_pages + 1,))
          response = MockPaginatorView.as_view()(request)
          content = json.loads(response.content)
          self.assertEqual(response.status_code, status.NOT_FOUND)
    def test_existing_query_parameters_are_preserved(self):
        """ Tests that existing query parameters are preserved when
        generating next/previous page links """
        request = self.req.get('/paginator/?foo=bar&another=something')
        response = MockPaginatorView.as_view()(request)
        content = json.loads(response.content)
        self.assertEqual(response.status_code, status.OK)
        self.assertTrue('foo=bar' in content['next'])
        self.assertTrue('another=something' in content['next'])
        self.assertTrue('page=2' in content['next'])
keep keep keep add
 Preserve existing query params in PaginatorMixin

Previously, generation of next/previous links would discard any existing
query parameters. This commit introduces a dependency on URLObject, which
is used to intelligently parse and modify URLs to ensure existing params
are preserved.

Addresses issues #107 
djangorestframework/tests/mixins.py