diff options
| author | Matheus Cunha Motta <sqrtomath@gmail.com> | 2020-02-26 15:08:55 -0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-02-28 08:38:57 +0100 |
| commit | e908eb62871f0b0aac63afa6601bf222bc2a1a7d (patch) | |
| tree | 34e86fecffb9be36411ee279eae0d9e3ed9b97ec | |
| parent | 308fab924195bdea2fc481e1466c3c3894c03400 (diff) | |
Fixed #31310 -- Fixed hints in checks for using intermediate model with ambiguous foreign key.
symmetrical=False is not required since
87b1ad6e7351464c60e751b483d9dfce3a2d3382.
| -rw-r--r-- | django/db/models/fields/related.py | 4 | ||||
| -rw-r--r-- | tests/invalid_models_tests/test_relative_fields.py | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 8ddbb5ba68..536b3dd601 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -1309,7 +1309,7 @@ class ManyToManyField(RelatedField): "through_fields keyword argument.") % (self, from_model_name), hint=( 'If you want to create a recursive relationship, ' - 'use ForeignKey("%s", symmetrical=False, through="%s").' + 'use ManyToManyField("%s", through="%s").' ) % ( RECURSIVE_RELATIONSHIP_CONSTANT, relationship_model_name, @@ -1329,7 +1329,7 @@ class ManyToManyField(RelatedField): "through_fields keyword argument." % (self, to_model_name), hint=( 'If you want to create a recursive relationship, ' - 'use ForeignKey("%s", symmetrical=False, through="%s").' + 'use ManyToManyField("%s", through="%s").' ) % ( RECURSIVE_RELATIONSHIP_CONSTANT, relationship_model_name, diff --git a/tests/invalid_models_tests/test_relative_fields.py b/tests/invalid_models_tests/test_relative_fields.py index a23e8bf044..7e32cced60 100644 --- a/tests/invalid_models_tests/test_relative_fields.py +++ b/tests/invalid_models_tests/test_relative_fields.py @@ -150,15 +150,14 @@ class RelativeFieldTests(SimpleTestCase): "through_fields keyword argument.", hint=( 'If you want to create a recursive relationship, use ' - 'ForeignKey("self", symmetrical=False, ' - 'through="AmbiguousRelationship").' + 'ManyToManyField("self", through="AmbiguousRelationship").' ), obj=field, id='fields.E334', ), ]) - def test_ambiguous_relationship_model(self): + def test_ambiguous_relationship_model_to(self): class Person(models.Model): pass @@ -182,7 +181,7 @@ class RelativeFieldTests(SimpleTestCase): "keyword argument.", hint=( 'If you want to create a recursive relationship, use ' - 'ForeignKey("self", symmetrical=False, through="AmbiguousRelationship").' + 'ManyToManyField("self", through="AmbiguousRelationship").' ), obj=field, id='fields.E335', |
