diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-08 04:21:39 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-02-08 04:21:39 +0000 |
| commit | 755bb2a3f2c7e59f2b7cb7daacb65acad79c7e19 (patch) | |
| tree | b80c35adb80e12fa04e27eb459a14b58aafb5ad0 | |
| parent | 0a07dac8805c451df5b4e8da2705849aea15ac01 (diff) | |
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
| -rw-r--r-- | django/db/models/query.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 193624144d..1a3a0b55ec 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -78,7 +78,11 @@ class _QuerySet(object): # The result cache has only been partially populated, so we may # need to fill it out a bit more. 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: bound = k + 1 if len(self._result_cache) < bound: @@ -87,7 +91,15 @@ class _QuerySet(object): if isinstance(k, slice): 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 try: qs = self._clone() |
