summaryrefslogtreecommitdiff
path: root/tests/modeladmin/test_checks.py
diff options
context:
space:
mode:
authorParth Paradkar <parthparadkar3@gmail.com>2026-01-12 19:16:22 +0530
committerGitHub <noreply@github.com>2026-01-12 08:46:22 -0500
commiteeea8d2cba41229b10226d8b9be184f0b015e95c (patch)
treea724ad290db092a91978c046a132dbc73c13134a /tests/modeladmin/test_checks.py
parentd61838761f17d7c934c7be288fadfa14f471b598 (diff)
Fixed #36804 -- Fixed admin system check crash for missing models.
Diffstat (limited to 'tests/modeladmin/test_checks.py')
-rw-r--r--tests/modeladmin/test_checks.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py
index fbd63abfbf..c493148eb9 100644
--- a/tests/modeladmin/test_checks.py
+++ b/tests/modeladmin/test_checks.py
@@ -1724,6 +1724,28 @@ class AutocompleteFieldsTests(CheckTestCase):
invalid_obj=Admin,
)
+ @isolate_apps("modeladmin")
+ def test_autocomplete_e039_unresolved_model(self):
+ class UnresolvedForeignKeyModel(models.Model):
+ unresolved = models.ForeignKey("missing.Model", models.CASCADE)
+
+ class Meta:
+ app_label = "modeladmin"
+
+ class Admin(ModelAdmin):
+ autocomplete_fields = ("unresolved",)
+
+ self.assertIsInvalid(
+ Admin,
+ UnresolvedForeignKeyModel,
+ msg=(
+ 'An admin for model "missing.Model" has to be registered '
+ "to be referenced by Admin.autocomplete_fields."
+ ),
+ id="admin.E039",
+ invalid_obj=Admin,
+ )
+
def test_autocomplete_e040(self):
class NoSearchFieldsAdmin(ModelAdmin):
pass