﻿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
36802	ManyToManyField Table name changed (django 5.2 > django 6.0)	ericmuijs		"Dear Django community. 

Just upgraded to django 6. Most things seem to work fine. However, I get an error when loading a fixture (during my tests) which has a many to many relationship. The error is, table does not exists. The table does exists, but somehow gets a different name in the (test database) compared to my dev database. The difference in name is related to plural name vs normal name.

Naming of the many to many table:
- Dev Database (tables created by django 5) : base_vergunningproductgroep_producten (plural name of related model)
- Test database (tables created by django 6) : base_vergunningproductgroep_product (just the name of the related 
 
No code is changed, except for the upgrade to django 6.

{{{
# Removed some unrelated fields for clarity

class VergunningProductGroep(TenantModel):
    vergunning = models.ForeignKey(Vergunning, on_delete=models.CASCADE, related_name='vergunningproducten')
    producten = models.ManyToManyField(Product, related_name='vergunningproductgroepen')

class Product(TenantModel):
    product_code = models.CharField(max_length=50)   
    omschrijving = models.CharField(max_length=50)
    
    class Meta:
        verbose_name = ""product""
        verbose_name_plural = ""producten""
        unique_together = ('tenant', 'product_code')
        ordering = ['tenant','product_code']
        indexes = [
            models.Index(fields=['tenant', 'product_code'])
        ]
}}}

**Solution tried**
I tried to hardcode the db_table using:
{{{
class VergunningProductGroep(TenantModel):
    vergunning = models.ForeignKey(Vergunning, on_delete=models.CASCADE, related_name='vergunningproducten')
    producten = models.ManyToManyField(Product, related_name='vergunningproductgroepen', db_table='vergunningproductgroep_producten')
}}}

After running ""makemigrations"" I expect the issue to be resolved, but to no avail. db_table seems to be ignored completely.

I already reported it [https://code.djangoproject.com/ticket/36800], but based on my limited knowledge, it does seem unrelated to renaming? Sorry if this tends to be a duplicate.
"	Uncategorized	new	Database layer (models, ORM)	6.0	Normal				Unreviewed	0	0	0	0	0	0
