MCPcopy
hub / github.com/ormar-orm/ormar / exclude_fields

Method exclude_fields

ormar/queryset/queryset.py:592–619  ·  view source on GitHub ↗

With `exclude_fields()` you can select subset of model columns that will be excluded to limit the data load. It's the opposite of `fields()` method so check documentation above to see what options are available. Especially check above how you can pass also

(self, columns: Union[list, str, set, dict])

Source from the content-addressed store, hash-verified

590 return self.rebuild_self(excludable=excludable)
591
592 def exclude_fields(self, columns: Union[list, str, set, dict]) -> "QuerySet[T]":
593 """
594 With `exclude_fields()` you can select subset of model columns that will
595 be excluded to limit the data load.
596
597 It's the opposite of `fields()` method so check documentation above
598 to see what options are available.
599
600 Especially check above how you can pass also nested dictionaries
601 and sets as a mask to exclude fields from whole hierarchy.
602
603 Note that `fields()` and `exclude_fields()` works both for main models
604 (on normal queries like `get`, `all` etc.)
605 as well as `select_related` and `prefetch_related` models
606 (with nested notation).
607
608 Mandatory fields cannot be excluded as it will raise `ValidationError`,
609 to exclude a field it has to be nullable.
610
611 Pk column cannot be excluded - it's always auto added even
612 if explicitly excluded.
613
614 :param columns: columns to exclude
615 :type columns: Union[list, str, set, dict]
616 :return: QuerySet
617 :rtype: QuerySet
618 """
619 return self.fields(columns=columns, slot="exclude")
620
621 def order_by(self, columns: Union[list, str, OrderAction]) -> "QuerySet[T]":
622 """

Calls 1

fieldsMethod · 0.95