diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-01-14 16:44:17 +0100 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-15 13:44:23 +0100 |
| commit | de9f46d7074a948d781b31476bb12a3ed017c8c0 (patch) | |
| tree | a6ac764e91d7dd0ccfa5789c5d4a043833b8dcf8 | |
| parent | f054045973ea767ee4e3d60723de4a2f13bf0c49 (diff) | |
Fixed #36070 -- Clarified model validation behavior for composite pks.
| -rw-r--r-- | docs/topics/composite-primary-key.txt | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/topics/composite-primary-key.txt b/docs/topics/composite-primary-key.txt index 883c1b3e6f..68356593b4 100644 --- a/docs/topics/composite-primary-key.txt +++ b/docs/topics/composite-primary-key.txt @@ -186,6 +186,16 @@ field :exc:`.FieldError`. :attr:`.Field.editable` to ``False`` on all primary key fields to exclude them from ModelForms. +Composite primary keys in model validation +========================================== + +Since ``pk`` is only a virtual field, including ``pk`` as a field name in the +``exclude`` argument of :meth:`.Model.clean_fields` has no effect. To exclude +the composite primary key fields from +:ref:`model validation <validating-objects>`, specify each field individually. +:meth:`.Model.validate_unique` can still be called with ``exclude={"pk"}`` to +skip uniqueness checks. + Building composite primary key ready applications ================================================= |
