1
0
mirror of https://github.com/django/django.git synced 2025-01-07 00:46:08 +00:00

Fixed #36037 -- Fixed default primary key type in docs.

BigAutoField is the default type for primary keys. In models.txt, the linked
anchor shows that the default primary key is a BigAutoField, so it now defers
to that section instead of duplicating an (incorrect) type.
This commit is contained in:
Ari Pollak 2024-12-23 16:26:01 -05:00 committed by Sarah Boyce
parent 82b913cd6c
commit ad385ae163
2 changed files with 4 additions and 4 deletions

View File

@ -261,7 +261,7 @@ For example, it could be used for a tagging system like so::
class TaggedItem(models.Model):
tag = models.SlugField()
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
object_id = models.PositiveBigIntegerField()
content_object = GenericForeignKey("content_type", "object_id")
def __str__(self):
@ -291,7 +291,7 @@ model:
2. Give your model a field that can store primary key values from the
models you'll be relating to. For most models, this means a
:class:`~django.db.models.PositiveIntegerField`. The usual name
:class:`~django.db.models.PositiveBigIntegerField`. The usual name
for this field is "object_id".
3. Give your model a

View File

@ -241,8 +241,8 @@ ones:
If ``True``, this field is the primary key for the model.
If you don't specify :attr:`primary_key=True <Field.primary_key>` for
any fields in your model, Django will automatically add an
:class:`IntegerField` to hold the primary key, so you don't need to set
any fields in your model, Django will automatically add a field to hold
the primary key, so you don't need to set
:attr:`primary_key=True <Field.primary_key>` on any of your fields
unless you want to override the default primary-key behavior. For more,
see :ref:`automatic-primary-key-fields`.