[Django] #36037: Documentation mentions default primary key being regular IntegerField, not BigAutoField

23 views
Skip to first unread message

Django

unread,
Dec 24, 2024, 3:22:08 PM12/24/24
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: aripollak | Type:
| Cleanup/optimization
Status: new | Component:
| Documentation
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Currently, Django's default primary key type is a BigAutoField. However, a
couple of pages still talk about it being an IntegerField.

Under https://docs.djangoproject.com/en/5.1/topics/db/models/#field-
options:

If you don’t specify primary_key=True for any fields in your model, Django
will automatically add an IntegerField to hold the primary key, so you
don’t need to set primary_key=True on any of your fields unless you want
to override the default primary-key behavior. For more, see Automatic
primary key fields

Under https://docs.djangoproject.com/en/5.1/ref/contrib/contenttypes
/#generic-relations:

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
PositiveIntegerField. The usual name for this field is “object_id”.
--
Ticket URL: <https://code.djangoproject.com/ticket/36037>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 24, 2024, 3:27:38 PM12/24/24
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: Ari Pollak | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Ari Pollak:

Old description:

> Currently, Django's default primary key type is a BigAutoField. However,
> a couple of pages still talk about it being an IntegerField.
>
> Under https://docs.djangoproject.com/en/5.1/topics/db/models/#field-
> options:
>
> If you don’t specify primary_key=True for any fields in your model,
> Django will automatically add an IntegerField to hold the primary key, so
> you don’t need to set primary_key=True on any of your fields unless you
> want to override the default primary-key behavior. For more, see
> Automatic primary key fields
>
> Under https://docs.djangoproject.com/en/5.1/ref/contrib/contenttypes
> /#generic-relations:
>
> 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
> PositiveIntegerField. The usual name for this field is “object_id”.

New description:

BigAutoField is the default type of primary key now, and in Postgres,
regular IntegerField only goes up to around 2 billion. However, a couple
of pages still talk about the default primary key being an IntegerField.

Under https://docs.djangoproject.com/en/5.1/topics/db/models/#field-
options:

If you don’t specify primary_key=True for any fields in your model, Django
will automatically add an IntegerField to hold the primary key, so you
don’t need to set primary_key=True on any of your fields unless you want
to override the default primary-key behavior. For more, see Automatic
primary key fields

Under https://docs.djangoproject.com/en/5.1/ref/contrib/contenttypes
/#generic-relations:

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
PositiveIntegerField. The usual name for this field is “object_id”.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36037#comment:1>

Django

unread,
Dec 24, 2024, 3:29:08 PM12/24/24
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: aripollak | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by aripollak):

Pull request: https://github.com/django/django/pull/18970
--
Ticket URL: <https://code.djangoproject.com/ticket/36037#comment:2>

Django

unread,
Dec 25, 2024, 3:38:56 AM12/25/24
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: Ari Pollak | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by dimen61):

Hi, Ari. Since you are working with this issue, please update the tag
"Owned by" to youself.
--
Ticket URL: <https://code.djangoproject.com/ticket/36037#comment:3>

Django

unread,
Dec 26, 2024, 9:16:27 AM12/26/24
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: Ari Pollak | Owner: Ari
Type: | Pollak
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by JaeHyuckSa):

* owner: (none) => Ari Pollak
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/36037#comment:4>

Django

unread,
Dec 26, 2024, 10:55:21 AM12/26/24
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: Ari Pollak | Owner: Ari
Type: | Pollak
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/36037#comment:5>

Django

unread,
Jan 2, 2025, 7:43:35 AM1/2/25
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: Ari Pollak | Owner: Ari
Type: | Pollak
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/36037#comment:6>

Django

unread,
Jan 2, 2025, 9:26:08 AM1/2/25
to django-...@googlegroups.com
#36037: Documentation mentions default primary key being regular IntegerField, not
BigAutoField
-------------------------------------+-------------------------------------
Reporter: Ari Pollak | Owner: Ari
Type: | Pollak
Cleanup/optimization | Status: closed
Component: Documentation | Version: 5.1
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"ad385ae163da2b1c558f62c0415db5aa03227587" ad385ae]:
{{{#!CommitTicketReference repository=""
revision="ad385ae163da2b1c558f62c0415db5aa03227587"
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.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36037#comment:7>
Reply all
Reply to author
Forward
0 new messages