#36343: Uprading to Django 5.2 from Django 5.1.7 creates a new migration for a 
self
referencing through model
---------------------------------+-----------------------------------------
     Reporter:  Mark Chackerian  |                     Type:  Uncategorized
       Status:  new              |                Component:  Uncategorized
      Version:  5.2              |                 Severity:  Normal
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+-----------------------------------------
 I have a model with a self-referential through model like


 {{{
 class Cad((models.Model):
     id = models.UUIDField(primary_key=True, default=uuid.uuid4,
 editable=False)
     cads: models.ManyToManyField = models.ManyToManyField(
         "self", symmetrical=False, through="CadChild",
 through_fields=("parent", "child")
     )
    ...

 class CadChild(models.Model):
     """A through model for Cad parent/child many-to-many relationships."""

     parent = models.ForeignKey(
         Cad,
         on_delete=models.CASCADE,
         related_name="parent_cad_set",
     )
     child = models.ForeignKey(
         Cad,
         on_delete=models.CASCADE,
         related_name="child_cad_set",
     )

 }}}


 When I upgraded from 5.1.7 to 5.2 I needed to created to create a new
 migration, which looked like:

 {{{
 # Generated by Django 5.2 on 2025-04-21 13:25

 from django.db import migrations, models




 class Migration(migrations.Migration):

     dependencies = [
         ('projects',
 '0012_documentpagetheme_documentpagethemeuserdefault'),
     ]

     operations = [
         migrations.AlterField(
             model_name='cad',
             name='cads',
             field=models.ManyToManyField(through='projects.CadChild',
 through_fields=('parent', 'child'), to='projects.cad'),
         ),
     ]

 }}}


 ----

 This may be intended behavior but I can't find any reference to this
 change in the release notes.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36343>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019658b10c57-66405e8c-5c6e-405b-8fee-20730e96841d-000000%40eu-central-1.amazonses.com.

Reply via email to