﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36343	Uprading to Django 5.2 from Django 5.1.7 creates a new migration for a self referencing through model	Mark Chackerian		"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."	Uncategorized	closed	Uncategorized	5.2	Normal	invalid			Unreviewed	0	0	0	0	0	0
