Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

queryset-refactor: Made none() a method on Querysets, as the document…

…ation

indicates (it was only added to managers in [4394]. Refs #6177.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7232 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9f0fb3dcc9d24ec1f5abb83dfb58b6da5a6d4baa 1 parent c8b33b8
Malcolm Tredinnick authored March 13, 2008
6  django/db/models/query.py
@@ -293,6 +293,12 @@ def dates(self, field_name, kind, order='ASC'):
293 293
         return self._clone(klass=DateQuerySet, setup=True, _field=field,
294 294
                 _kind=kind, _order=order)
295 295
 
  296
+    def none(self):
  297
+        """
  298
+        Returns an empty queryset.
  299
+        """
  300
+        return self._clone(klass=EmptyQuerySet)
  301
+
296 302
     ##################################################################
297 303
     # PUBLIC METHODS THAT ALTER ATTRIBUTES AND RETURN A NEW QUERYSET #
298 304
     ##################################################################
2  tests/modeltests/lookup/models.py
@@ -254,6 +254,8 @@ def __unicode__(self):
254 254
 []
255 255
 >>> Article.objects.none().filter(headline__startswith='Article')
256 256
 []
  257
+>>> Article.objects.filter(headline__startswith='Article').none()
  258
+[]
257 259
 >>> Article.objects.none().count()
258 260
 0
259 261
 >>> [article for article in Article.objects.none().iterator()]

0 notes on commit 9f0fb3d

Please sign in to comment.
Something went wrong with that request. Please try again.