Merge pull request #1931 from bagerard/fix_no_dereference_doc_asserts

fix some asserts in no_dereference doc
This commit is contained in:
erdenezul 2018-10-25 10:15:33 +08:00 committed by GitHub
commit 4f157f50ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -456,14 +456,14 @@ data. To turn off dereferencing of the results of a query use
:func:`~mongoengine.queryset.QuerySet.no_dereference` on the queryset like so:: :func:`~mongoengine.queryset.QuerySet.no_dereference` on the queryset like so::
post = Post.objects.no_dereference().first() post = Post.objects.no_dereference().first()
assert(isinstance(post.author, ObjectId)) assert(isinstance(post.author, DBRef))
You can also turn off all dereferencing for a fixed period by using the You can also turn off all dereferencing for a fixed period by using the
:class:`~mongoengine.context_managers.no_dereference` context manager:: :class:`~mongoengine.context_managers.no_dereference` context manager::
with no_dereference(Post) as Post: with no_dereference(Post) as Post:
post = Post.objects.first() post = Post.objects.first()
assert(isinstance(post.author, ObjectId)) assert(isinstance(post.author, DBRef))
# Outside the context manager dereferencing occurs. # Outside the context manager dereferencing occurs.
assert(isinstance(post.author, User)) assert(isinstance(post.author, User))