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)
| 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()` |