--
Ticket URL: <https://code.djangoproject.com/ticket/32294>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> Django raises an error during creation a db migration if two models with
> the same refer to the same model in m2m field. related_name='+' or 'foo+'
> don't impact anything.
> In some my project there are 50 apps and almost each one has a model with
> the same name. So I have to come up with a related name and write it in
> for each m2m field.
> Just try to make a migration for my test project
> https://github.com/rafick1983/django_related_name_bug
New description:
Django raises an error during creation a db migration if two models with
the same name refer to the same model in m2m field. related_name='+' or
'foo+' don't impact anything.
In some my project there are 50 apps and almost each one has a model with
the same name. So I have to come up with a related name and write it in
for each m2m field.
Just try to make a migration for my test project
https://github.com/rafick1983/django_related_name_bug
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32294#comment:1>
* stage: Unreviewed => Accepted
Comment:
Thanks for the report. It looks that `app_label` is missing in
[https://github.com/django/django/blob/c76d51b3ad34bc2ed2155054bfb283ef53beb26a/django/db/models/fields/related.py#L1619-L1623
ManyToManyField.contribute_to_class()]:
{{{
self.remote_field.related_name = "_%s_%s_%s_+" % (cls._meta.app_label,
cls.__name__.lower(), name)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32294#comment:2>
* easy: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/32294#comment:3>
* owner: nobody => Manav Agarwal
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/32294#comment:4>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/13822 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/32294#comment:5>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32294#comment:6>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a9a7421ab83361746549d574ca13438ba93c95fe" a9a7421a]:
{{{
#!CommitTicketReference repository=""
revision="a9a7421ab83361746549d574ca13438ba93c95fe"
Fixed #32294 -- Prevented ManyToManyField's hidden related name collisions
between apps.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32294#comment:7>