Skip to content

Define default_auto_field to silence Django 3.2+ warnings#96

Merged
nicholasserra merged 1 commit into
revsys:masterfrom
blag:update-for-modern-django
Nov 18, 2025
Merged

Define default_auto_field to silence Django 3.2+ warnings#96
nicholasserra merged 1 commit into
revsys:masterfrom
blag:update-for-modern-django

Conversation

@blag
Copy link
Copy Markdown
Contributor

@blag blag commented Nov 18, 2025

tos.TermsOfService: (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 TOSConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
tos.UserAgreement: (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 TOSConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

It's an easy fix.

@nicholasserra
Copy link
Copy Markdown
Collaborator

Thanks! This didn't trigger a new migration?

@blag
Copy link
Copy Markdown
Contributor Author

blag commented Nov 18, 2025

It didn't for me, because Django previously silently defaulted to using AutoField. This change just makes the default explicit. If a user specifies DEFAULT_AUTO_FIELD in their settings.py it will override this one.

If I had switched it to BigAutoField I think it would have triggered a migration. I considered that, but I'll leave that to users to figure out if they need that or not and set in DEFAULT_AUTO_FIELD if so.

@nicholasserra
Copy link
Copy Markdown
Collaborator

Sounds right, thank you!

@nicholasserra nicholasserra merged commit 39ea711 into revsys:master Nov 18, 2025
8 checks passed
@blag blag deleted the update-for-modern-django branch November 19, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants