Add validation for clashing ManyToManyField.db_table names
|Reported by:||strelnikovdmitrij||Owned by:||christopherdcunha|
|Component:||Core (System checks)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
Description (last modified by Alex)
Originally from documentation.
The name of the table to create for storing the many-to-many data. If this is not provided, Django will assume a default name based upon the names of the two tables being joined.
It is a little bit unclear, cause if db_table is not provided, Django will create table with name based on the name of the model (table that has the ManyToManyField), and field name that contain this ManyToManyField.
class Product(models.Model): color = models.ManyToManyField('ProductColor', null=True, blank=True) class Meta: db_table = 'eshop_product' class ProductColor(models.Model): name = ... class Meta: db_table = 'eshop_product_color'
after the creation of 'eshop_product' table Django will create 'eshop_product_color' table that holds relation between Product and ProductColor. The table for ProductColor will never create.
Change History (13)
comment:1 Changed 5 years ago by Alex
- Description modified (diff)
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 5 years ago by russellm
- Component changed from Documentation to django-admin.py
- milestone set to 1.2
- Triage Stage changed from Unreviewed to Accepted
comment:13 Changed 7 months ago by christopherdcunha
- Owner changed from nobody to christopherdcunha
- Status changed from new to assigned
comment:14 Changed 7 months ago by timo
- Component changed from Core (Management commands) to Core (System checks)
- Has patch set
- Summary changed from ManyToManyField.db_table to Add validation for clashing ManyToManyField.db_table names