mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
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>
This commit is contained in:
committed by
Sarah Boyce
parent
86661f2449
commit
978aae4334
@@ -31,6 +31,25 @@ and only officially support the latest release of each series.
|
||||
What's new in Django 5.2
|
||||
========================
|
||||
|
||||
Composite Primary Keys
|
||||
----------------------
|
||||
|
||||
The new :class:`django.db.models.CompositePrimaryKey` allows tables to be
|
||||
created with a primary key consisting of multiple fields.
|
||||
|
||||
To use a composite primary key, when creating a model set the ``pk`` field to
|
||||
be a ``CompositePrimaryKey``::
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Release(models.Model):
|
||||
pk = models.CompositePrimaryKey("version", "name")
|
||||
version = models.IntegerField()
|
||||
name = models.CharField(max_length=20)
|
||||
|
||||
See :doc:`/topics/composite-primary-key` for more details.
|
||||
|
||||
Minor features
|
||||
--------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user