mirror of
https://github.com/django/django.git
synced 2025-11-12 16:47:49 +00:00
Fixed #24156 -- Fixed inherited related name of ManyToManyField.
Fixed situation when parent abstract model declares related_name='+', and child models had an invalid queryset.
This commit is contained in:
parent
ec74dba2ab
commit
f7b2978158
5 changed files with 55 additions and 13 deletions
|
|
@ -2626,7 +2626,7 @@ class ManyToManyField(RelatedField):
|
|||
# related_name with one generated from the m2m field name. Django
|
||||
# still uses backwards relations internally and we need to avoid
|
||||
# clashes between multiple m2m fields with related_name == '+'.
|
||||
self.remote_field.related_name = "_%s_+" % name
|
||||
self.remote_field.related_name = "_%s_%s_+" % (cls.__name__.lower(), name)
|
||||
|
||||
super(ManyToManyField, self).contribute_to_class(cls, name, **kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue