Fixed #21375 -- related_name='+' clashed with other '+' names
This commit is contained in:
parent
18c642b96c
commit
9f76ea1eaa
|
@ -309,7 +309,7 @@ def get_validation_errors(outfile, app=None):
|
||||||
# occurs for symmetrical m2m relations to self). If this is the
|
# occurs for symmetrical m2m relations to self). If this is the
|
||||||
# case, there are no clashes to check for this field, as there are
|
# case, there are no clashes to check for this field, as there are
|
||||||
# no reverse descriptors for this field.
|
# no reverse descriptors for this field.
|
||||||
if rel_name is not None:
|
if not f.rel.is_hidden():
|
||||||
for r in rel_opts.fields:
|
for r in rel_opts.fields:
|
||||||
if r.name == rel_name:
|
if r.name == rel_name:
|
||||||
e.add(opts, "Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name))
|
e.add(opts, "Accessor for m2m field '%s' clashes with field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.name, f.name))
|
||||||
|
|
|
@ -25,3 +25,24 @@ class ThingWithIterableChoices(models.Model):
|
||||||
# Testing choices= Iterable of Iterables
|
# Testing choices= Iterable of Iterables
|
||||||
# See: https://code.djangoproject.com/ticket/20430
|
# See: https://code.djangoproject.com/ticket/20430
|
||||||
thing = models.CharField(max_length=100, blank=True, choices=Things())
|
thing = models.CharField(max_length=100, blank=True, choices=Things())
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
# Models created as unmanaged as these aren't ever queried
|
||||||
|
managed = False
|
||||||
|
|
||||||
|
|
||||||
|
class ManyToManyRel(models.Model):
|
||||||
|
thing1 = models.ManyToManyField(ThingWithIterableChoices, related_name='+')
|
||||||
|
thing2 = models.ManyToManyField(ThingWithIterableChoices, related_name='+')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
# Models created as unmanaged as these aren't ever queried
|
||||||
|
managed = False
|
||||||
|
|
||||||
|
class FKRel(models.Model):
|
||||||
|
thing1 = models.ForeignKey(ThingWithIterableChoices, related_name='+')
|
||||||
|
thing2 = models.ForeignKey(ThingWithIterableChoices, related_name='+')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
# Models created as unmanaged as these aren't ever queried
|
||||||
|
managed = False
|
||||||
|
|
|
@ -10,4 +10,6 @@ class ModelValidationTest(TestCase):
|
||||||
# Validation Tests:
|
# Validation Tests:
|
||||||
# * choices= Iterable of Iterables
|
# * choices= Iterable of Iterables
|
||||||
# See: https://code.djangoproject.com/ticket/20430
|
# See: https://code.djangoproject.com/ticket/20430
|
||||||
|
# * related_name='+' doesn't clash with another '+'
|
||||||
|
# See: https://code.djangoproject.com/ticket/21375
|
||||||
management.call_command("validate", stdout=six.StringIO())
|
management.call_command("validate", stdout=six.StringIO())
|
||||||
|
|
Loading…
Reference in New Issue