Skip to content

Commit

Permalink
DEFAULT_AUTO_FIELD to avoid deprecation warnings
Browse files Browse the repository at this point in the history
The default (new in Django 3.2) is BigAutoField, but we have many models that were created with the old default. It is easier to set our global default to `AutoField` since that does not require migrating existing fields. If in the future we decide to change `DEFAULT_AUTO_FIELD` from `AutoField` to `BigAutoField` we have these options for existing models with implicit primary keys:

- Migrate primary key to `BigAutoField`.
- Explicitly add `id = models.AutoField(primary_key=True)` to override the default (also requires a state-only migration).
  • Loading branch information
millerdev committed Mar 31, 2022
1 parent a95d02d commit b927572
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@
)

ROOT_URLCONF = "urls"
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

DEFAULT_APPS = (
'django.contrib.admin',
Expand Down

0 comments on commit b927572

Please sign in to comment.