summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorBendeguz Csirmaz <csirmazbendeguz@gmail.com>2024-04-07 10:32:16 +0800
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-11-29 11:23:04 +0100
commit978aae4334fa71ba78a3e94408f0f3aebde8d07c (patch)
treedd1cc322769441a3dd28b952ce52e07c3f72f90a /docs/ref
parent86661f2449fb0903f72b3522c68e146934013377 (diff)
Fixed #373 -- Added CompositePrimaryKey.
Thanks Lily Foote and Simon Charette for reviews and mentoring this Google Summer of Code 2024 project. Co-authored-by: Simon Charette <charette.s@gmail.com> Co-authored-by: Lily Foote <code@lilyf.org>
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/checks.txt3
-rw-r--r--docs/ref/models/fields.txt19
2 files changed, 22 insertions, 0 deletions
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 2308a854c7..b0a98bde28 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -181,6 +181,7 @@ Model fields
* **fields.E011**: ``<database>`` does not support default database values with
expressions (``db_default``).
* **fields.E012**: ``<expression>`` cannot be used in ``db_default``.
+* **fields.E013**: ``CompositePrimaryKey`` must be named ``pk``.
* **fields.E100**: ``AutoField``\s must set primary_key=True.
* **fields.E110**: ``BooleanField``\s do not accept null values. *This check
appeared before support for null values was added in Django 2.1.*
@@ -417,6 +418,8 @@ Models
* **models.W040**: ``<database>`` does not support indexes with non-key
columns.
* **models.E041**: ``constraints`` refers to the joined field ``<field name>``.
+* **models.E042**: ``<field name>`` cannot be included in the composite
+ primary key.
* **models.W042**: Auto-created primary key used when not defining a primary
key type, by default ``django.db.models.AutoField``.
* **models.W043**: ``<database>`` does not support indexes on expressions.
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 07e86785d9..5b0f127c6f 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -707,6 +707,23 @@ or :class:`~django.forms.NullBooleanSelect` if :attr:`null=True <Field.null>`.
The default value of ``BooleanField`` is ``None`` when :attr:`Field.default`
isn't defined.
+``CompositePrimaryKey``
+-----------------------
+
+.. versionadded:: 5.2
+
+.. class:: CompositePrimaryKey(*field_names, **options)
+
+A virtual field used for defining a composite primary key.
+
+This field must be defined as the model's ``pk`` field. If present, Django will
+create the underlying model table with a composite primary key.
+
+The ``*field_names`` argument is a list of positional field names that compose
+the primary key.
+
+See :doc:`/topics/composite-primary-key` for more details.
+
``CharField``
-------------
@@ -1615,6 +1632,8 @@ not an instance of ``UUID``.
hyphens, because PostgreSQL and MariaDB 10.7+ store them in a hyphenated
uuid datatype type.
+.. _relationship-fields:
+
Relationship fields
===================