Django

Code

Changeset 6600

Show
Ignore:
Timestamp:
10/23/07 08:49:07 (9 months ago)
Author:
mtredinnick
Message:

queryset-refactor: Added a convenience all() method to Querysets. Refs #3739

Files:

Legend:

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

    r6599 r6600  
    246246    # PUBLIC METHODS THAT ALTER ATTRIBUTES AND RETURN A NEW QUERYSET # 
    247247    ################################################################## 
     248 
     249    def all(self): 
     250        """ 
     251        Returns a new QuerySet that is a copy of the current one. This allows a 
     252        QuerySet to proxy for a model manager in some cases. 
     253        """ 
     254        return self._clone() 
    248255 
    249256    def filter(self, *args, **kwargs): 
  • django/branches/queryset-refactor/docs/db-api.txt

    r6520 r6600  
    682682    [] 
    683683 
     684``all()`` 
     685~~~~~~~~~~ 
     686 
     687**New in Django development version** 
     688 
     689Returns a ''copy'' of the current ``QuerySet`` (or ``QuerySet`` subclass you 
     690pass in). This can be useful in some situations where you might want to pass 
     691in either a model manager or a ``QuerySet`` and do further filtering on the 
     692result. You can safely call ``all()`` on either object and then you'll 
     693definitely have a ``QuerySet`` to work with. 
     694 
    684695``select_related()`` 
    685696~~~~~~~~~~~~~~~~~~~~ 
  • django/branches/queryset-refactor/tests/regressiontests/queries/models.py

    r6521 r6600  
    375375[] 
    376376 
     377Bug #3739 
     378The all() method on querysets returns a copy of the queryset. 
     379>>> q1 = Item.objects.order_by('name') 
     380>>> id(q1) == id(q1.all()) 
     381False 
    377382"""} 
    378383