#36564: Change DEFAULT_AUTO_FIELD to BigAutoField
-------------------------------------+-------------------------------------
Reporter: Tim | Owner: Tim Graham
Graham |
Type: | Status: assigned
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
In Django 3.2, the `DEFAULT_AUTO_FIELD` setting and
`AppConfig.default_auto_field` attribute were added to start nudging users
from `AutoField` to `BigAutoField`.
The default `startproject` template has `DEFAULT_AUTO_FIELD =
'django.db.models.BigAutoField'` and the default startapp template has
`default_auto_field = ‘django.db.models.BigAutoField'` but
`django.conf.global_settings` has `DEFAULT_AUTO_FIELD =
"django.db.models.AutoField"`.
Phase two of the plan is changing the `DEFAULT_AUTO_FIELD` in
`django.conf.global_settings` to `BigAutoField`. Since there has has
effectively been a quasi-deprecation warning generated by the system check
framework since Django 3.2 if neither `DEFAULT_AUTO_FIELD` nor
`AppConfig.default_auto_field` are set, I think no deprecation period is
needed and we can make these changes in Django 6.0:
* Change `django.conf.global_settings.DEFAULT_AUTO_FIELD` from `AutoField`
to `BigAutoField`.
* Remove `DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'` from the
default project template.
* Remove `default_auto_field = 'django.db.models.BigAutoField'` from the
default app template.
* Remove the system check that’s acted as a deprecation warning (example
output below):
{{{
WARNINGS:
app_label.Model: (models.W042) Auto-created primary key used when not
defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the
AppConfig.default_auto_field attribute to point to a subclass of
AutoField, e.g. 'django.db.models.BigAutoField'.
}}}
When [
https://forum.djangoproject.com/t/changing-default-auto-field-to-
bigautofield/42452 raised on the forum], the only concern is whether the
fellows will have time to review the patch.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36564>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.