mirror of
https://github.com/django/django.git
synced 2025-07-06 18:59:13 +00:00
queryset-refactor: Added (back) in support for using strings in slices.
Apparently there exists code that like to do this, including the admin interface. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0a07dac880
commit
755bb2a3f2
@ -78,7 +78,11 @@ class _QuerySet(object):
|
|||||||
# The result cache has only been partially populated, so we may
|
# The result cache has only been partially populated, so we may
|
||||||
# need to fill it out a bit more.
|
# need to fill it out a bit more.
|
||||||
if isinstance(k, slice):
|
if isinstance(k, slice):
|
||||||
bound = k.stop
|
if k.stop is not None:
|
||||||
|
# Some people insist on passing in strings here.
|
||||||
|
bound = int(k.stop)
|
||||||
|
else:
|
||||||
|
bound = None
|
||||||
else:
|
else:
|
||||||
bound = k + 1
|
bound = k + 1
|
||||||
if len(self._result_cache) < bound:
|
if len(self._result_cache) < bound:
|
||||||
@ -87,7 +91,15 @@ class _QuerySet(object):
|
|||||||
|
|
||||||
if isinstance(k, slice):
|
if isinstance(k, slice):
|
||||||
qs = self._clone()
|
qs = self._clone()
|
||||||
qs.query.set_limits(k.start, k.stop)
|
if k.start is not None:
|
||||||
|
start = int(k.start)
|
||||||
|
else:
|
||||||
|
start = None
|
||||||
|
if k.stop is not None:
|
||||||
|
stop = int(k.stop)
|
||||||
|
else:
|
||||||
|
stop = None
|
||||||
|
qs.query.set_limits(start, stop)
|
||||||
return k.step and list(qs)[::k.step] or qs
|
return k.step and list(qs)[::k.step] or qs
|
||||||
try:
|
try:
|
||||||
qs = self._clone()
|
qs = self._clone()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user