mirror of
https://github.com/django/django.git
synced 2025-11-25 21:22:14 +00:00
Fixed #26827 -- Improved ModelState error message when relations refer model classes.
This commit is contained in:
parent
a89c715c3b
commit
a8adb6aa6c
3 changed files with 11 additions and 8 deletions
|
|
@ -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)])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue