diff options
| author | Tom Forbes <tom@tomforb.es> | 2020-07-12 13:59:57 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-12-15 11:25:46 +0100 |
| commit | b5e12d490af3debca8c55ab3c1698189fdedbbdb (patch) | |
| tree | 5fe3005ac567f3addf78b81ae033191e2fa642f4 /docs/topics | |
| parent | b960e4ed722a04a9db0d35293f76e253eedf9126 (diff) | |
Fixed #31007 -- Allowed specifying type of auto-created primary keys.
This also changes the default type of auto-created primary keys
for new apps and projects to BigAutoField.
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/db/models.txt | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt index 81eb5b516b..26a6d7dc58 100644 --- a/docs/topics/db/models.txt +++ b/docs/topics/db/models.txt @@ -259,11 +259,12 @@ details can be found in the :ref:`common model field option reference Automatic primary key fields ---------------------------- -By default, Django gives each model the following field:: +By default, Django gives each model an auto-incrementing primary key with the +type specified per app in :attr:`AppConfig.default_auto_field +<django.apps.AppConfig.default_auto_field>` or globally in the +:setting:`DEFAULT_AUTO_FIELD` setting. For example:: - id = models.AutoField(primary_key=True) - -This is an auto-incrementing primary key. + id = models.BigAutoField(primary_key=True) If you'd like to specify a custom primary key, specify :attr:`primary_key=True <Field.primary_key>` on one of your fields. If Django @@ -273,6 +274,11 @@ sees you've explicitly set :attr:`Field.primary_key`, it won't add the automatic Each model requires exactly one field to have :attr:`primary_key=True <Field.primary_key>` (either explicitly declared or automatically added). +.. versionchanged:: 3.2 + + In older versions, auto-created primary key fields were always + :class:`AutoField`\s. + .. _verbose-field-names: Verbose field names |
