1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #26827 -- Improved ModelState error message when relations refer model classes.

This commit is contained in:
Prashant Pandey
2023-11-23 10:29:52 +05:30
committed by Mariusz Felisiak
parent a89c715c3b
commit a8adb6aa6c
3 changed files with 11 additions and 8 deletions

View File

@@ -1651,8 +1651,8 @@ class ModelStateTests(SimpleTestCase):
field = models.ForeignKey(UnicodeModel, models.CASCADE)
with self.assertRaisesMessage(
ValueError,
'ModelState.fields cannot refer to a model class - "field.to" does. '
"Use a string reference instead.",
'Model fields in "ModelState.fields" cannot refer to a model class - '
'"app.Model.field.to" does. Use a string reference instead.',
):
ModelState("app", "Model", [("field", field)])
@@ -1661,8 +1661,8 @@ class ModelStateTests(SimpleTestCase):
field.remote_field.through = UnicodeModel
with self.assertRaisesMessage(
ValueError,
'ModelState.fields cannot refer to a model class - "field.through" does. '
"Use a string reference instead.",
'Model fields in "ModelState.fields" cannot refer to a model class - '
'"app.Model.field.through" does. Use a string reference instead.',
):
ModelState("app", "Model", [("field", field)])