#12810: ManyToManyField.db_table
----------------------------------------+-----------------------------------
          Reporter:  strelnikovdmitrij  |         Owner:  nobody         
            Status:  new                |     Milestone:                 
         Component:  Documentation      |       Version:  SVN            
        Resolution:                     |      Keywords:  ManyToManyField
             Stage:  Unreviewed         |     Has_patch:  0              
        Needs_docs:  0                  |   Needs_tests:  0              
Needs_better_patch:  0                  |  
----------------------------------------+-----------------------------------
Changes (by Alex):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Old description:

> Originally from documentation.
> ManyToManyField.db_table
> 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'
>
> running syncdb
> 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.

New description:

 Originally from documentation.
 ManyToManyField.db_table
 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'
 }}}
 running syncdb
 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.

Comment:

 Reformatted, please use preview.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12810#comment:1>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to