MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / exclude

Method exclude

mongoengine/queryset/base.py:1056–1072  ·  view source on GitHub ↗

Opposite to .only(), exclude some document's fields. :: post = BlogPost.objects(...).exclude('comments') .. note :: `exclude()` is chainable and will perform a union :: So with the following it will exclude both: `title` and `author.name`:: post = B

(self, *fields)

Source from the content-addressed store, hash-verified

1054 return self.fields(True, **fields)
1055
1056 def exclude(self, *fields):
1057 """Opposite to .only(), exclude some document's fields. ::
1058
1059 post = BlogPost.objects(...).exclude('comments')
1060
1061 .. note :: `exclude()` is chainable and will perform a union ::
1062 So with the following it will exclude both: `title` and `author.name`::
1063
1064 post = BlogPost.objects.exclude('title').exclude('author.name')
1065
1066 :func:`~mongoengine.queryset.QuerySet.all_fields` will reset any
1067 field filters.
1068
1069 :param fields: fields to exclude
1070 """
1071 fields = {f: QueryFieldList.EXCLUDE for f in fields}
1072 return self.fields(**fields)
1073
1074 def fields(self, _only_called=False, **kwargs):
1075 """Manipulate how you load this document's fields. Used by `.only()`

Callers 15

test_slicingMethod · 0.45
test_excludeMethod · 0.45
test_all_fieldsMethod · 0.45
test_updateMethod · 0.45
test_covered_indexMethod · 0.45

Calls 1

fieldsMethod · 0.95

Tested by 15

test_slicingMethod · 0.36
test_excludeMethod · 0.36
test_all_fieldsMethod · 0.36
test_updateMethod · 0.36
test_covered_indexMethod · 0.36