Django

Code

Changeset 7094

Show
Ignore:
Timestamp:
02/07/08 22:21:39 (1 year ago)
Author:
mtredinnick
Message:

queryset-refactor: Added (back) in support for using strings in slices.

Apparently there exists code that like to do this, including the admin
interface.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/django/db/models/query.py

    r7092 r7094  
    7979                # need to fill it out a bit more. 
    8080                if isinstance(k, slice): 
    81                     bound = k.stop 
     81                    if k.stop is not None: 
     82                        # Some people insist on passing in strings here. 
     83                        bound = int(k.stop) 
     84                    else: 
     85                        bound = None 
    8286                else: 
    8387                    bound = k + 1 
     
    8892        if isinstance(k, slice): 
    8993            qs = self._clone() 
    90             qs.query.set_limits(k.start, k.stop) 
     94            if k.start is not None: 
     95                start = int(k.start) 
     96            else: 
     97                start = None 
     98            if k.stop is not None: 
     99                stop = int(k.stop) 
     100            else: 
     101                stop = None 
     102            qs.query.set_limits(start, stop) 
    91103            return k.step and list(qs)[::k.step] or qs 
    92104        try: