Fixed #23812 - Replaced every range and xrange with django.utils.six.moves.range

Please wrap [line 2475](https://github.com/Siecje/django/blob/%2323812/tests/queries/tests.py#L2475) with `list`. See http://djangoci.com/job/django-pull-requests/1576/database=oracle11,python=python2.7/testReport/junit/queries.tests/ConditionalTests/test_ticket14244/ for the stacktrace.