Author: mtredinnick
Date: 2007-10-23 08:49:07 -0500 (Tue, 23 Oct 2007)
New Revision: 6600
Modified:
django/branches/queryset-refactor/django/db/models/query.py
django/branches/queryset-refactor/docs/db-api.txt
django/branches/queryset-refactor/tests/regressiontests/queries/models.py
Log:
queryset-refactor: Added a convenience all() method to Querysets. Refs #3739
Modified: django/branches/queryset-refactor/django/db/models/query.py
===================================================================
--- django/branches/queryset-refactor/django/db/models/query.py 2007-10-23
13:34:03 UTC (rev 6599)
+++ django/branches/queryset-refactor/django/db/models/query.py 2007-10-23
13:49:07 UTC (rev 6600)
@@ -246,6 +246,13 @@
# PUBLIC METHODS THAT ALTER ATTRIBUTES AND RETURN A NEW QUERYSET #
##################################################################
+ def all(self):
+ """
+ Returns a new QuerySet that is a copy of the current one. This allows a
+ QuerySet to proxy for a model manager in some cases.
+ """
+ return self._clone()
+
def filter(self, *args, **kwargs):
"""
Returns a new QuerySet instance with the args ANDed to the existing
Modified: django/branches/queryset-refactor/docs/db-api.txt
===================================================================
--- django/branches/queryset-refactor/docs/db-api.txt 2007-10-23 13:34:03 UTC
(rev 6599)
+++ django/branches/queryset-refactor/docs/db-api.txt 2007-10-23 13:49:07 UTC
(rev 6600)
@@ -681,6 +681,17 @@
>>> Entry.objects.none()
[]
+``all()``
+~~~~~~~~~~
+
+**New in Django development version**
+
+Returns a ''copy'' of the current ``QuerySet`` (or ``QuerySet`` subclass you
+pass in). This can be useful in some situations where you might want to pass
+in either a model manager or a ``QuerySet`` and do further filtering on the
+result. You can safely call ``all()`` on either object and then you'll
+definitely have a ``QuerySet`` to work with.
+
``select_related()``
~~~~~~~~~~~~~~~~~~~~
Modified:
django/branches/queryset-refactor/tests/regressiontests/queries/models.py
===================================================================
--- django/branches/queryset-refactor/tests/regressiontests/queries/models.py
2007-10-23 13:34:03 UTC (rev 6599)
+++ django/branches/queryset-refactor/tests/regressiontests/queries/models.py
2007-10-23 13:49:07 UTC (rev 6600)
@@ -374,5 +374,10 @@
>>> X.objects.select_related()
[]
+Bug #3739
+The all() method on querysets returns a copy of the queryset.
+>>> q1 = Item.objects.order_by('name')
+>>> id(q1) == id(q1.all())
+False
"""}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---