Skip to content

Commit fae14f2

Browse files
committed
edit error message
1 parent 961e358 commit fae14f2

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

django_mongodb_backend/fields/embedded_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ def check(self, **kwargs):
2424
if field.remote_field:
2525
errors.append(
2626
checks.Error(
27-
"Embedded models cannot have relational fields.",
27+
"Embedded models cannot have relational fields "
28+
f"({self.embedded_model().__class__.__name__}.{field.name} "
29+
f"is a {field.__class__.__name__}).",
2830
obj=self,
2931
id="django_mongodb.embedded_model.E001",
3032
)
@@ -46,9 +48,7 @@ def get_internal_type(self):
4648
def _set_model(self, model):
4749
"""
4850
Resolve embedded model class once the field knows the model it belongs
49-
to.
50-
51-
If __init__()'s embedded_model argument is a string, resolve it to the
51+
to. If __init__()'s embedded_model argument is a string, resolve it to the
5252
corresponding model class, similar to relation fields.
5353
"""
5454
self._model = model

django_mongodb_backend/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _create_model_indexes(self, model, column_prefix="", parent_model=None):
3535
Create all indexes (field indexes & uniques, Meta.index_together,
3636
Meta.unique_together, Meta.constraints, Meta.indexes) for the model.
3737
38-
If this is a recursive call to due to an embedded model, `column_prefix`
38+
If this is a recursive call due to an embedded model, `column_prefix`
3939
tracks the path that must be prepended to the index's column, and
4040
`parent_model` tracks the collection to add the index/constraint to.
4141
"""

tests/model_fields_/test_embedded_model.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,6 @@ class MyModel(models.Model):
135135
# The inner CharField has a non-positive max_length.
136136
self.assertEqual(errors[0].id, "django_mongodb.embedded_model.E001")
137137
msg = errors[0].msg
138-
self.assertEqual(msg, "Embedded models cannot have relational fields.")
138+
self.assertEqual(
139+
msg, "Embedded models cannot have relational fields (Target.key is a ForeignKey)."
140+
)

0 commit comments

Comments
 (0)