From a6c9281b6a5fc419dfe2c2f6c3f5143b4925eab6 Mon Sep 17 00:00:00 2001 From: johnthagen Date: Wed, 6 Oct 2021 13:44:12 -0400 Subject: [PATCH] Add tip about using values() to exclude required fields --- docs/queries/select-columns.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/queries/select-columns.md b/docs/queries/select-columns.md index 8064e96..9648317 100644 --- a/docs/queries/select-columns.md +++ b/docs/queries/select-columns.md @@ -109,6 +109,9 @@ assert all_cars[0].manufacturer.founded == 1937 Mandatory fields cannot be excluded as it will raise `ValidationError`, to exclude a field it has to be nullable. + The `values()` method can be used to exclude mandatory fields, though data will + be returned as a `dict`. + You cannot exclude mandatory model columns - `manufacturer__name` in this example. ```python @@ -274,6 +277,9 @@ await Car.objects.select_related('manufacturer').exclude_fields([{'company': {'n Mandatory fields cannot be excluded as it will raise `ValidationError`, to exclude a field it has to be nullable. + The `values()` method can be used to exclude mandatory fields, though data will + be returned as a `dict`. + !!!tip Pk column cannot be excluded - it's always auto added even if explicitly excluded.