mirror of
https://github.com/django/django.git
synced 2025-03-12 18:30:48 +00:00
Fixed #36070 -- Clarified model validation behavior for composite pks.
This commit is contained in:
parent
f054045973
commit
de9f46d707
@ -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
|
||||
=================================================
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user