#12810: ManyToManyField.db_table
----------------------------------------+-----------------------------------
          Reporter:  strelnikovdmitrij  |         Owner:  nobody         
            Status:  new                |     Milestone:  1.2            
         Component:  django-admin.py    |       Version:  SVN            
        Resolution:                     |      Keywords:  ManyToManyField
             Stage:  Accepted           |     Has_patch:  0              
        Needs_docs:  0                  |   Needs_tests:  0              
Needs_better_patch:  0                  |  
----------------------------------------+-----------------------------------
Comment (by coleifer):

 This one is pretty hard to validate against, since the m2m_db_table gets
 set when the ManyToManyField contributes to class, and any other models
 that may cause conflicts might not be loaded yet.

 One way to get this to work is to specify db_table on your
 ManyToManyField::


 {{{
 from django.db import models

 class Product(models.Model):
     color = models.ManyToManyField('ProductColor',
 db_table='eshop_product_color_rel',
                                    null=True, blank=True)
     class Meta:
         db_table = 'eshop_product'

 class ProductColor(models.Model):
     name = models.CharField(max_length=200)
     class Meta:
         db_table = 'eshop_product_color'

 }}}

 Your table gets created correctly:

 {{{
 char...@charles-laptop:~/tmp/test_m2m_collision$ ./manage.py syncdb
 Creating table django_session
 Creating table eshop_product_color_rel
 Creating table eshop_product
 Creating table eshop_product_color
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12810#comment:4>
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