Removed __len__ from queryset (#247)

This commit is contained in:
Ross Lawley
2013-04-22 16:19:55 +00:00
parent efad628a87
commit 0d0befe23e
8 changed files with 82 additions and 70 deletions

View File

@@ -4,7 +4,8 @@ Changelog
Changes in 0.8.X
================
- Objects manager now inherited (#256)
- Removed __len__ from queryset (#247)
- Objects queryset manager now inherited (#256)
- Updated connection to use MongoClient (#262, #274)
- Fixed db_alias and inherited Documents (#143)
- Documentation update for document errors (#124)

View File

@@ -45,7 +45,7 @@ print 'ALL POSTS'
print
for post in Post.objects:
print post.title
print '=' * len(post.title)
print '=' * post.title.count()
if isinstance(post, TextPost):
print post.content

View File

@@ -79,6 +79,9 @@ the case and the data is set only in the ``document._data`` dictionary: ::
Querysets
=========
Attack of the clones
--------------------
Querysets now return clones and should no longer be considered editable in
place. This brings us in line with how Django's querysets work and removes a
long running gotcha. If you edit your querysets inplace you will have to
@@ -98,6 +101,19 @@ update your code like so: ::
mammals = Animal.objects(type="mammal").filter(order="Carnivora") # The final queryset is assgined to mammals
[m for m in mammals] # This will return all carnivores
No more len
-----------
If you ever did len(queryset) it previously did a count() under the covers, this
caused some unusual issues - so now it has been removed in favour of the
explicit `queryset.count()` to update::
# Old code
len(Animal.objects(type="mammal"))
# New code
Animal.objects(type="mammal").count())
Client
======
PyMongo 2.4 came with a new connection client; MongoClient_ and started the