Skip to content

Commit

Permalink
queryset-refactor: Made none() a method on Querysets, as the document…
Browse files Browse the repository at this point in the history
…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
malcolmt committed Mar 13, 2008
1 parent c8b33b8 commit 9f0fb3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions django/db/models/query.py
Expand Up @@ -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 #
##################################################################
Expand Down
2 changes: 2 additions & 0 deletions tests/modeltests/lookup/models.py
Expand Up @@ -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()]
Expand Down

0 comments on commit 9f0fb3d

Please sign in to comment.