Fixed #31310 -- Fixed hints in checks for using intermediate model with ambiguous foreign key.

symmetrical=False is not required since
87b1ad6e73.
This commit is contained in:
Matheus Cunha Motta 2020-02-26 15:08:55 -03:00 committed by Mariusz Felisiak
parent 308fab9241
commit e908eb6287
2 changed files with 5 additions and 6 deletions

View File

@ -1309,7 +1309,7 @@ class ManyToManyField(RelatedField):
"through_fields keyword argument.") % (self, from_model_name), "through_fields keyword argument.") % (self, from_model_name),
hint=( hint=(
'If you want to create a recursive relationship, ' 'If you want to create a recursive relationship, '
'use ForeignKey("%s", symmetrical=False, through="%s").' 'use ManyToManyField("%s", through="%s").'
) % ( ) % (
RECURSIVE_RELATIONSHIP_CONSTANT, RECURSIVE_RELATIONSHIP_CONSTANT,
relationship_model_name, relationship_model_name,
@ -1329,7 +1329,7 @@ class ManyToManyField(RelatedField):
"through_fields keyword argument." % (self, to_model_name), "through_fields keyword argument." % (self, to_model_name),
hint=( hint=(
'If you want to create a recursive relationship, ' 'If you want to create a recursive relationship, '
'use ForeignKey("%s", symmetrical=False, through="%s").' 'use ManyToManyField("%s", through="%s").'
) % ( ) % (
RECURSIVE_RELATIONSHIP_CONSTANT, RECURSIVE_RELATIONSHIP_CONSTANT,
relationship_model_name, relationship_model_name,

View File

@ -150,15 +150,14 @@ class RelativeFieldTests(SimpleTestCase):
"through_fields keyword argument.", "through_fields keyword argument.",
hint=( hint=(
'If you want to create a recursive relationship, use ' 'If you want to create a recursive relationship, use '
'ForeignKey("self", symmetrical=False, ' 'ManyToManyField("self", through="AmbiguousRelationship").'
'through="AmbiguousRelationship").'
), ),
obj=field, obj=field,
id='fields.E334', id='fields.E334',
), ),
]) ])
def test_ambiguous_relationship_model(self): def test_ambiguous_relationship_model_to(self):
class Person(models.Model): class Person(models.Model):
pass pass
@ -182,7 +181,7 @@ class RelativeFieldTests(SimpleTestCase):
"keyword argument.", "keyword argument.",
hint=( hint=(
'If you want to create a recursive relationship, use ' 'If you want to create a recursive relationship, use '
'ForeignKey("self", symmetrical=False, through="AmbiguousRelationship").' 'ManyToManyField("self", through="AmbiguousRelationship").'
), ),
obj=field, obj=field,
id='fields.E335', id='fields.E335',