Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@malcolmt malcolmt authored
Showing with 8 additions and 0 deletions.
  1. +6 −0 django/db/models/query.py
  2. +2 −0  tests/modeltests/lookup/models.py
View
6 django/db/models/query.py
@@ -293,6 +293,12 @@ def dates(self, field_name, kind, order='ASC'):
return self._clone(klass=DateQuerySet, setup=True, _field=field,
_kind=kind, _order=order)
+ def none(self):
+ """
+ Returns an empty queryset.
+ """
+ return self._clone(klass=EmptyQuerySet)
+
##################################################################
# PUBLIC METHODS THAT ALTER ATTRIBUTES AND RETURN A NEW QUERYSET #
##################################################################
View
2  tests/modeltests/lookup/models.py
@@ -254,6 +254,8 @@ def __unicode__(self):
[]
>>> Article.objects.none().filter(headline__startswith='Article')
[]
+>>> Article.objects.filter(headline__startswith='Article').none()
+[]
>>> Article.objects.none().count()
0
>>> [article for article in Article.objects.none().iterator()]

0 comments on commit 9f0fb3d

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