summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2025-08-19 15:08:43 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2025-09-05 10:43:10 -0400
commit2a636118dacdcda074c99ebd50311d64a8cca367 (patch)
treef5b11c60f9fd598429d6ab60b35515a6c6d82256
parent0ddbe12ea99a2dc1b757dc2015ba8bb6bfd9d653 (diff)
Fixed #36564 -- Changed DEFAULT_AUTO_FIELD from AutoField to BigAutoField.
-rw-r--r--django/conf/app_template/apps.py-tpl1
-rw-r--r--django/conf/global_settings.py2
-rw-r--r--django/conf/project_template/project_name/settings.py-tpl5
-rw-r--r--django/db/backends/postgresql/features.py9
-rw-r--r--django/db/models/base.py33
-rw-r--r--docs/intro/reusable-apps.txt1
-rw-r--r--docs/ref/checks.txt3
-rw-r--r--docs/ref/settings.txt7
-rw-r--r--docs/releases/6.0.txt30
-rw-r--r--tests/admin_scripts/tests.py6
-rw-r--r--tests/check_framework/apps.py10
-rw-r--r--tests/check_framework/test_model_checks.py135
-rw-r--r--tests/introspection/tests.py2
-rw-r--r--tests/migrations/test_migrations_no_changes/0001_initial.py4
-rw-r--r--tests/migrations/test_migrations_no_changes/0002_second.py2
-rw-r--r--tests/migrations/test_migrations_no_changes/0003_third.py4
-rw-r--r--tests/migrations/test_migrations_no_default/0001_initial.py2
-rw-r--r--tests/model_inheritance/test_abstract_inheritance.py10
-rw-r--r--tests/model_options/test_default_pk.py8
-rw-r--r--tests/postgres_tests/array_default_migrations/0001_initial.py2
-rw-r--r--tests/postgres_tests/array_index_migrations/0001_initial.py2
-rw-r--r--tests/postgres_tests/migrations/0002_create_test_models.py54
-rw-r--r--tests/postgres_tests/models.py6
-rw-r--r--tests/postgres_tests/test_constraints.py2
-rw-r--r--tests/schema/tests.py24
-rw-r--r--tests/test_sqlite.py2
26 files changed, 114 insertions, 252 deletions
diff --git a/django/conf/app_template/apps.py-tpl b/django/conf/app_template/apps.py-tpl
index b705352181..9b2ce5289c 100644
--- a/django/conf/app_template/apps.py-tpl
+++ b/django/conf/app_template/apps.py-tpl
@@ -2,5 +2,4 @@ from django.apps import AppConfig
class {{ camel_case_app_name }}Config(AppConfig):
- default_auto_field = 'django.db.models.BigAutoField'
name = '{{ app_name }}'
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 3d4c6f4a5f..77f2b83e68 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -436,7 +436,7 @@ DEFAULT_TABLESPACE = ""
DEFAULT_INDEX_TABLESPACE = ""
# Default primary key field type.
-DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
+DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# Default X-Frame-Options header value
X_FRAME_OPTIONS = "DENY"
diff --git a/django/conf/project_template/project_name/settings.py-tpl b/django/conf/project_template/project_name/settings.py-tpl
index 5631ec9a31..c2d24e4df0 100644
--- a/django/conf/project_template/project_name/settings.py-tpl
+++ b/django/conf/project_template/project_name/settings.py-tpl
@@ -115,8 +115,3 @@ USE_TZ = True
# https://docs.djangoproject.com/en/{{ docs_version }}/howto/static-files/
STATIC_URL = 'static/'
-
-# Default primary key field type
-# https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/#default-auto-field
-
-DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
diff --git a/django/db/backends/postgresql/features.py b/django/db/backends/postgresql/features.py
index 83e6b5cf7f..419fad8686 100644
--- a/django/db/backends/postgresql/features.py
+++ b/django/db/backends/postgresql/features.py
@@ -123,6 +123,15 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"test_group_by_nested_expression_with_params",
}
)
+ if not is_psycopg3:
+ expected_failures.update(
+ {
+ # operator does not exist: bigint[] = integer[]
+ "postgres_tests.test_array.TestQuerying.test_gt",
+ "postgres_tests.test_array.TestQuerying.test_in",
+ "postgres_tests.test_array.TestQuerying.test_lt",
+ }
+ )
return expected_failures
@cached_property
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 7c20319da6..3827b00346 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1701,7 +1701,6 @@ class Model(AltersData, metaclass=ModelBase):
*cls._check_indexes(databases),
*cls._check_ordering(),
*cls._check_constraints(databases),
- *cls._check_default_pk(),
*cls._check_db_table_comment(databases),
*cls._check_composite_pk(),
]
@@ -1709,38 +1708,6 @@ class Model(AltersData, metaclass=ModelBase):
return errors
@classmethod
- def _check_default_pk(cls):
- if (
- not cls._meta.abstract
- and cls._meta.pk.auto_created
- and
- # Inherited PKs are checked in parents models.
- not (
- isinstance(cls._meta.pk, OneToOneField)
- and cls._meta.pk.remote_field.parent_link
- )
- and not settings.is_overridden("DEFAULT_AUTO_FIELD")
- and cls._meta.app_config
- and not cls._meta.app_config._is_default_auto_field_overridden
- ):
- return [
- checks.Warning(
- f"Auto-created primary key used when not defining a "
- f"primary key type, by default "
- f"'{settings.DEFAULT_AUTO_FIELD}'.",
- hint=(
- f"Configure the DEFAULT_AUTO_FIELD setting or the "
- f"{cls._meta.app_config.__class__.__qualname__}."
- f"default_auto_field attribute to point to a subclass "
- f"of AutoField, e.g. 'django.db.models.BigAutoField'."
- ),
- obj=cls,
- id="models.W042",
- ),
- ]
- return []
-
- @classmethod
def _check_composite_pk(cls):
errors = []
meta = cls._meta
diff --git a/docs/intro/reusable-apps.txt b/docs/intro/reusable-apps.txt
index 723f752cc5..6c953a4043 100644
--- a/docs/intro/reusable-apps.txt
+++ b/docs/intro/reusable-apps.txt
@@ -153,7 +153,6 @@ this. For a small app like polls, this process isn't too difficult.
class PollsConfig(AppConfig):
- default_auto_field = "django.db.models.BigAutoField"
name = "django_polls"
label = "polls"
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 36e6fe1d85..e1ea5bc753 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -429,7 +429,8 @@ Models
* **models.E042**: ``<field name>`` cannot be included in the composite
primary key.
* **models.W042**: Auto-created primary key used when not defining a primary
- key type, by default ``django.db.models.AutoField``.
+ key type, by default ``django.db.models.AutoField``. *This check appeared in
+ Django 3.2 - 5.2*.
* **models.W043**: ``<database>`` does not support indexes on expressions.
* **models.W044**: ``<database>`` does not support unique constraints on
expressions.
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index d5b7f2ad05..33e16695d2 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -1279,11 +1279,16 @@ See also :setting:`NUMBER_GROUPING`, :setting:`THOUSAND_SEPARATOR` and
``DEFAULT_AUTO_FIELD``
----------------------
-Default: ``'``:class:`django.db.models.AutoField`\ ``'``
+Default: ``'``:class:`django.db.models.BigAutoField`\ ``'``
Default primary key field type to use for models that don't have a field with
:attr:`primary_key=True <django.db.models.Field.primary_key>`.
+.. versionchanged:: 6.0
+
+ In older versions, the default value is
+ :class:`django.db.models.AutoField`.
+
.. admonition:: Migrating auto-created through tables
The value of ``DEFAULT_AUTO_FIELD`` will be respected when creating new
diff --git a/docs/releases/6.0.txt b/docs/releases/6.0.txt
index efc8a5bf41..6ba28b464d 100644
--- a/docs/releases/6.0.txt
+++ b/docs/releases/6.0.txt
@@ -458,6 +458,36 @@ Email
significantly, closely examine any custom subclasses that rely on overriding
undocumented, internal underscore methods.
+``DEFAULT_AUTO_FIELD`` setting now defaults to ``BigAutoField``
+---------------------------------------------------------------
+
+Since Django 3.2 when the :setting:`DEFAULT_AUTO_FIELD` setting was added,
+the default :djadmin:`startproject` template's ``settings.py`` contained::
+
+ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
+
+and the default :djadmin:`startapp` template's ``AppConfig`` contained::
+
+ default_auto_field = "django.db.models.BigAutoField"
+
+At that time, the default value of :setting:`DEFAULT_AUTO_FIELD` remained
+:class:`django.db.models.AutoField` for backwards compatibility.
+
+In Django 6.0, :setting:`DEFAULT_AUTO_FIELD` now defaults to
+:class:`django.db.models.BigAutoField` and the aforementioned lines in the
+project and app templates are removed.
+
+Most projects shouldn't be affected since there has been a system check warning
+since Django 3.2 if a project doesn't set :setting:`DEFAULT_AUTO_FIELD`:
+
+ **models.W042**: Auto-created primary key used when not defining a primary
+ key type, by default ``django.db.models.AutoField``.
+
+If you haven't dealt with this warning by now, add
+``DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'`` to your project's
+settings, or ``default_auto_field = 'django.db.models.AutoField'`` to an app's
+``AppConfig``, as needed.
+
Custom ORM expressions should return params as a tuple
------------------------------------------------------
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 97d2d7cf7e..3718354dc7 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -75,7 +75,6 @@ class AdminScriptTestCase(SimpleTestCase):
settings_file.write("%s\n" % extra)
exports = [
"DATABASES",
- "DEFAULT_AUTO_FIELD",
"ROOT_URLCONF",
"SECRET_KEY",
"USE_TZ",
@@ -3127,11 +3126,6 @@ class StartApp(AdminScriptTestCase):
with open(os.path.join(app_path, "apps.py")) as f:
content = f.read()
self.assertIn("class NewAppConfig(AppConfig)", content)
- if HAS_BLACK:
- test_str = 'default_auto_field = "django.db.models.BigAutoField"'
- else:
- test_str = "default_auto_field = 'django.db.models.BigAutoField'"
- self.assertIn(test_str, content)
self.assertIn(
'name = "new_app"' if HAS_BLACK else "name = 'new_app'",
content,
diff --git a/tests/check_framework/apps.py b/tests/check_framework/apps.py
deleted file mode 100644
index b78d603855..0000000000
--- a/tests/check_framework/apps.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from django.apps import AppConfig
-
-
-class CheckDefaultPKConfig(AppConfig):
- name = "check_framework"
-
-
-class CheckPKConfig(AppConfig):
- name = "check_framework"
- default_auto_field = "django.db.models.BigAutoField"
diff --git a/tests/check_framework/test_model_checks.py b/tests/check_framework/test_model_checks.py
index be504f9c2d..18553cd7cb 100644
--- a/tests/check_framework/test_model_checks.py
+++ b/tests/check_framework/test_model_checks.py
@@ -1,5 +1,3 @@
-from unittest import mock
-
from django.core import checks
from django.core.checks import Error, Warning
from django.db import models
@@ -411,136 +409,3 @@ class ConstraintNameTests(TestCase):
constraints = [constraint]
self.assertEqual(checks.run_checks(app_configs=apps.get_app_configs()), [])
-
-
-def mocked_is_overridden(self, setting):
- # Force treating DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' as a not
- # overridden setting.
- return (
- setting != "DEFAULT_AUTO_FIELD"
- or self.DEFAULT_AUTO_FIELD != "django.db.models.AutoField"
- )
-
-
-@mock.patch("django.conf.UserSettingsHolder.is_overridden", mocked_is_overridden)
-@override_settings(DEFAULT_AUTO_FIELD="django.db.models.AutoField")
-@isolate_apps("check_framework.apps.CheckDefaultPKConfig", attr_name="apps")
-@override_system_checks([checks.model_checks.check_all_models])
-class ModelDefaultAutoFieldTests(SimpleTestCase):
- msg = (
- "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 "
- "CheckDefaultPKConfig.default_auto_field attribute to point to a "
- "subclass of AutoField, e.g. 'django.db.models.BigAutoField'."
- )
-
- def test_auto_created_pk(self):
- class Model(models.Model):
- pass
-
- self.assertEqual(
- checks.run_checks(app_configs=self.apps.get_app_configs()),
- [
- Warning(self.msg, hint=self.hint, obj=Model, id="models.W042"),
- ],
- )
-
- def test_explicit_inherited_pk(self):
- class Parent(models.Model):
- id = models.AutoField(primary_key=True)
-
- class Child(Parent):
- pass
-
- self.assertEqual(checks.run_checks(app_configs=self.apps.get_app_configs()), [])
-
- def test_skipped_on_model_with_invalid_app_label(self):
- class Model(models.Model):
- class Meta:
- app_label = "invalid_app_label"
-
- self.assertEqual(Model.check(), [])
-
- def test_skipped_on_abstract_model(self):
- class Abstract(models.Model):
- class Meta:
- abstract = True
-
- # Call .check() because abstract models are not registered.
- self.assertEqual(Abstract.check(), [])
-
- def test_explicit_inherited_parent_link(self):
- class Parent(models.Model):
- id = models.AutoField(primary_key=True)
-
- class Child(Parent):
- parent_ptr = models.OneToOneField(Parent, models.CASCADE, parent_link=True)
-
- self.assertEqual(checks.run_checks(app_configs=self.apps.get_app_configs()), [])
-
- def test_auto_created_inherited_pk(self):
- class Parent(models.Model):
- pass
-
- class Child(Parent):
- pass
-
- self.assertEqual(
- checks.run_checks(app_configs=self.apps.get_app_configs()),
- [
- Warning(self.msg, hint=self.hint, obj=Parent, id="models.W042"),
- ],
- )
-
- def test_auto_created_inherited_parent_link(self):
- class Parent(models.Model):
- pass
-
- class Child(Parent):
- parent_ptr = models.OneToOneField(Parent, models.CASCADE, parent_link=True)
-
- self.assertEqual(
- checks.run_checks(app_configs=self.apps.get_app_configs()),
- [
- Warning(self.msg, hint=self.hint, obj=Parent, id="models.W042"),
- ],
- )
-
- def test_auto_created_pk_inherited_abstract_parent(self):
- class Parent(models.Model):
- class Meta:
- abstract = True
-
- class Child(Parent):
- pass
-
- self.assertEqual(
- checks.run_checks(app_configs=self.apps.get_app_configs()),
- [
- Warning(self.msg, hint=self.hint, obj=Child, id="models.W042"),
- ],
- )
-
- @override_settings(DEFAULT_AUTO_FIELD="django.db.models.BigAutoField")
- def test_default_auto_field_setting(self):
- class Model(models.Model):
- pass
-
- self.assertEqual(checks.run_checks(app_configs=self.apps.get_app_configs()), [])
-
- def test_explicit_pk(self):
- class Model(models.Model):
- id = models.BigAutoField(primary_key=True)
-
- self.assertEqual(checks.run_checks(app_configs=self.apps.get_app_configs()), [])
-
- @isolate_apps("check_framework.apps.CheckPKConfig", kwarg_name="apps")
- def test_app_default_auto_field(self, apps):
- class ModelWithPkViaAppConfig(models.Model):
- class Meta:
- app_label = "check_framework.apps.CheckPKConfig"
-
- self.assertEqual(checks.run_checks(app_configs=apps.get_app_configs()), [])
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index dc17313cc4..327e5cc8c6 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -113,7 +113,7 @@ class IntrospectionTests(TransactionTestCase):
[
connection.features.introspected_field_types[field]
for field in (
- "AutoField",
+ "BigAutoField",
"CharField",
"CharField",
"CharField",
diff --git a/tests/migrations/test_migrations_no_changes/0001_initial.py b/tests/migrations/test_migrations_no_changes/0001_initial.py
index 42aadab7a0..8a5f1a3357 100644
--- a/tests/migrations/test_migrations_no_changes/0001_initial.py
+++ b/tests/migrations/test_migrations_no_changes/0001_initial.py
@@ -6,7 +6,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
"Author",
[
- ("id", models.AutoField(primary_key=True)),
+ ("id", models.BigAutoField(primary_key=True)),
("name", models.CharField(max_length=255)),
("slug", models.SlugField(null=True)),
("age", models.IntegerField(default=0)),
@@ -16,7 +16,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
"Tribble",
[
- ("id", models.AutoField(primary_key=True)),
+ ("id", models.BigAutoField(primary_key=True)),
("fluffy", models.BooleanField(default=True)),
],
),
diff --git a/tests/migrations/test_migrations_no_changes/0002_second.py b/tests/migrations/test_migrations_no_changes/0002_second.py
index 059b7ba2e7..0f2c4de209 100644
--- a/tests/migrations/test_migrations_no_changes/0002_second.py
+++ b/tests/migrations/test_migrations_no_changes/0002_second.py
@@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations.CreateModel(
"Book",
[
- ("id", models.AutoField(primary_key=True)),
+ ("id", models.BigAutoField(primary_key=True)),
(
"author",
models.ForeignKey("migrations.Author", models.SET_NULL, null=True),
diff --git a/tests/migrations/test_migrations_no_changes/0003_third.py b/tests/migrations/test_migrations_no_changes/0003_third.py
index e810902a40..1182bed53d 100644
--- a/tests/migrations/test_migrations_no_changes/0003_third.py
+++ b/tests/migrations/test_migrations_no_changes/0003_third.py
@@ -12,7 +12,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -28,7 +28,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
diff --git a/tests/migrations/test_migrations_no_default/0001_initial.py b/tests/migrations/test_migrations_no_default/0001_initial.py
index 5be2a9268e..f4395e7724 100644
--- a/tests/migrations/test_migrations_no_default/0001_initial.py
+++ b/tests/migrations/test_migrations_no_default/0001_initial.py
@@ -10,7 +10,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
diff --git a/tests/model_inheritance/test_abstract_inheritance.py b/tests/model_inheritance/test_abstract_inheritance.py
index 2dd183a200..f1de28d800 100644
--- a/tests/model_inheritance/test_abstract_inheritance.py
+++ b/tests/model_inheritance/test_abstract_inheritance.py
@@ -443,30 +443,30 @@ class AbstractInheritanceTests(SimpleTestCase):
self.assertEqual(
fields(model1),
[
- ("id", models.AutoField),
+ ("id", models.BigAutoField),
("name", models.CharField),
("age", models.IntegerField),
],
)
self.assertEqual(
- fields(model2), [("id", models.AutoField), ("name", models.CharField)]
+ fields(model2), [("id", models.BigAutoField), ("name", models.CharField)]
)
self.assertEqual(getattr(model2, "age"), 2)
self.assertEqual(
- fields(model3), [("id", models.AutoField), ("name", models.CharField)]
+ fields(model3), [("id", models.BigAutoField), ("name", models.CharField)]
)
self.assertEqual(
- fields(model4), [("id", models.AutoField), ("name", models.CharField)]
+ fields(model4), [("id", models.BigAutoField), ("name", models.CharField)]
)
self.assertEqual(getattr(model4, "age"), 2)
self.assertEqual(
fields(model5),
[
- ("id", models.AutoField),
+ ("id", models.BigAutoField),
("foo", models.IntegerField),
("concretemodel_ptr", models.OneToOneField),
("age", models.SmallIntegerField),
diff --git a/tests/model_options/test_default_pk.py b/tests/model_options/test_default_pk.py
index 896eddd828..49d57e3fd7 100644
--- a/tests/model_options/test_default_pk.py
+++ b/tests/model_options/test_default_pk.py
@@ -10,6 +10,14 @@ class MyBigAutoField(models.BigAutoField):
@isolate_apps("model_options")
class TestDefaultPK(SimpleTestCase):
+ def test_default_value_of_default_auto_field_setting(self):
+ """django.conf.global_settings defaults to BigAutoField."""
+
+ class MyModel(models.Model):
+ pass
+
+ self.assertIsInstance(MyModel._meta.pk, models.BigAutoField)
+
@override_settings(DEFAULT_AUTO_FIELD="django.db.models.NonexistentAutoField")
def test_default_auto_field_setting_nonexistent(self):
msg = (
diff --git a/tests/postgres_tests/array_default_migrations/0001_initial.py b/tests/postgres_tests/array_default_migrations/0001_initial.py
index 7a8c993f65..e725734b4b 100644
--- a/tests/postgres_tests/array_default_migrations/0001_initial.py
+++ b/tests/postgres_tests/array_default_migrations/0001_initial.py
@@ -11,7 +11,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
diff --git a/tests/postgres_tests/array_index_migrations/0001_initial.py b/tests/postgres_tests/array_index_migrations/0001_initial.py
index d08243b67e..b5fc4be725 100644
--- a/tests/postgres_tests/array_index_migrations/0001_initial.py
+++ b/tests/postgres_tests/array_index_migrations/0001_initial.py
@@ -11,7 +11,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
diff --git a/tests/postgres_tests/migrations/0002_create_test_models.py b/tests/postgres_tests/migrations/0002_create_test_models.py
index f9a102d3dc..859d45f29d 100644
--- a/tests/postgres_tests/migrations/0002_create_test_models.py
+++ b/tests/postgres_tests/migrations/0002_create_test_models.py
@@ -25,7 +25,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -44,7 +44,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -65,7 +65,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -85,7 +85,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -125,7 +125,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -134,7 +134,7 @@ class Migration(migrations.Migration):
),
(
"field",
- ArrayField(models.IntegerField(), blank=True, default=list),
+ ArrayField(models.BigIntegerField(), blank=True, default=list),
),
],
options={
@@ -147,7 +147,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -169,7 +169,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -191,7 +191,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -200,11 +200,13 @@ class Migration(migrations.Migration):
),
(
"field",
- ArrayField(models.IntegerField(), null=True, blank=True),
+ ArrayField(models.BigIntegerField(), null=True, blank=True),
),
(
"field_nested",
- ArrayField(ArrayField(models.IntegerField(null=True)), null=True),
+ ArrayField(
+ ArrayField(models.BigIntegerField(null=True)), null=True
+ ),
),
("order", models.IntegerField(null=True)),
],
@@ -218,7 +220,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -235,7 +237,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -272,7 +274,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -290,7 +292,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -307,7 +309,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -341,7 +343,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -363,7 +365,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -385,7 +387,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -412,7 +414,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -427,7 +429,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -442,7 +444,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -469,7 +471,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -508,7 +510,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -530,7 +532,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
@@ -545,7 +547,7 @@ class Migration(migrations.Migration):
fields=[
(
"id",
- models.AutoField(
+ models.BigAutoField(
verbose_name="ID",
serialize=False,
auto_created=True,
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py
index 1563f6a35d..f07f4492b8 100644
--- a/tests/postgres_tests/models.py
+++ b/tests/postgres_tests/models.py
@@ -45,12 +45,12 @@ class PostgreSQLModel(models.Model):
class IntegerArrayModel(PostgreSQLModel):
- field = ArrayField(models.IntegerField(), default=list, blank=True)
+ field = ArrayField(models.BigIntegerField(), default=list, blank=True)
class NullableIntegerArrayModel(PostgreSQLModel):
- field = ArrayField(models.IntegerField(), blank=True, null=True)
- field_nested = ArrayField(ArrayField(models.IntegerField(null=True)), null=True)
+ field = ArrayField(models.BigIntegerField(), blank=True, null=True)
+ field_nested = ArrayField(ArrayField(models.BigIntegerField(null=True)), null=True)
order = models.IntegerField(null=True)
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py
index f107bffcfe..bcc2b5f97d 100644
--- a/tests/postgres_tests/test_constraints.py
+++ b/tests/postgres_tests/test_constraints.py
@@ -821,7 +821,7 @@ class ExclusionConstraintTests(PostgreSQLTestCase):
OpClass(TsTzRange("start", "end", RangeBoundary()), "range_ops"),
RangeOperators.OVERLAPS,
),
- (OpClass("room", "gist_int4_ops"), RangeOperators.EQUAL),
+ (OpClass("room", "gist_int8_ops"), RangeOperators.EQUAL),
],
condition=Q(cancelled=False),
)
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index a06553e680..88d4ebbc8b 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -1697,7 +1697,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(Book)
self.assertEqual(
columns["author_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
self.assertForeignKeyExists(Book, "author_id", "schema_author")
# Alter the FK
@@ -1709,7 +1709,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(Book)
self.assertEqual(
columns["author_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
self.assertForeignKeyExists(Book, "author_id", "schema_author")
@@ -1761,7 +1761,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(BookWithO2O)
self.assertEqual(
columns["author_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
# Ensure the field is unique
author = Author.objects.create(name="Joe")
@@ -1783,7 +1783,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(Book)
self.assertEqual(
columns["author_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
# Ensure the field is not unique anymore
Book.objects.create(
@@ -1807,7 +1807,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(Book)
self.assertEqual(
columns["author_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
# Ensure the field is not unique
author = Author.objects.create(name="Joe")
@@ -1828,7 +1828,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(BookWithO2O)
self.assertEqual(
columns["author_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
# Ensure the field is unique now
BookWithO2O.objects.create(
@@ -1901,7 +1901,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(Author)
field_type, _ = columns["note_ptr_id"]
self.assertEqual(
- field_type, connection.features.introspected_field_types["IntegerField"]
+ field_type, connection.features.introspected_field_types["BigIntegerField"]
)
def test_alter_field_fk_keeps_index(self):
@@ -2506,7 +2506,7 @@ class SchemaTests(TransactionTestCase):
)
self.assertEqual(
columns["tagm2mtest_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
def test_m2m_create(self):
@@ -2551,11 +2551,11 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(LocalTagThrough)
self.assertEqual(
columns["book_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
self.assertEqual(
columns["tag_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
def test_m2m_create_through(self):
@@ -2651,7 +2651,7 @@ class SchemaTests(TransactionTestCase):
columns = self.column_classes(new_field.remote_field.through)
self.assertEqual(
columns["tagm2mtest_id"][0],
- connection.features.introspected_field_types["IntegerField"],
+ connection.features.introspected_field_types["BigIntegerField"],
)
# "Alter" the field. This should not rename the DB table to itself.
@@ -4537,7 +4537,7 @@ class SchemaTests(TransactionTestCase):
letters.
"""
- def get_field(*args, field_class=IntegerField, **kwargs):
+ def get_field(*args, field_class=BigIntegerField, **kwargs):
kwargs["db_column"] = "CamelCase"
field = field_class(*args, **kwargs)
field.set_attributes_from_name("CamelCase")
diff --git a/tests/test_sqlite.py b/tests/test_sqlite.py
index 1cdc6976b3..0e6b0f672a 100644
--- a/tests/test_sqlite.py
+++ b/tests/test_sqlite.py
@@ -28,6 +28,4 @@ PASSWORD_HASHERS = [
"django.contrib.auth.hashers.MD5PasswordHasher",
]
-DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
-
USE_TZ = False