#28309: Migration bug in related_name for ManyToManyField with self
-------------------------------------+-------------------------------------
               Reporter:  Ahmed      |          Owner:  nobody
  Mohamed                            |
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  1.11
  Migrations                         |       Keywords:  ManyToManyField
               Severity:  Normal     |  self
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 The related_name is not set correctly on ManyToManyField when it is
 related with 'self'. When I use the model name explicitly, it is set
 correctly.


 {{{
 class Model1(models.Model):
     children = models.ManyToManyField('self', blank=True,
 related_name='parents')

 class Model2(models.Model):
     children = models.ManyToManyField('self', blank=True,
 related_name='parents')
 }}}


 {{{
 migrations.CreateModel(
     name='Model1',
     fields=[
         ('id', models.AutoField(auto_created=True, primary_key=True,
 serialize=False, verbose_name='ID')),
         ('children', models.ManyToManyField(blank=True,
 related_name='_model1_children_+', to='raftprot.Model1')),
     ],
 ),
 migrations.CreateModel(
     name='Model2',
     fields=[
         ('id', models.AutoField(auto_created=True, primary_key=True,
 serialize=False, verbose_name='ID')),
         ('children', models.ManyToManyField(blank=True,
 related_name='parents', to='raftprot.Model2')),
     ],
 ),
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28309>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.e58d94bc780831d84fad631d2c3fc887%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to