----------
from django.db import models
class Phone(models.Model):
id = models.AutoField(primary_key=True, db_column='id')
type = models.CharField(max_length=1, db_column='Type',
null=False, blank=False)
status = models.CharField(max_length=1, db_column='Status',
null=False, blank=False)
country_code = models.CharField(max_length=3, db_column='Country',
blank=True)
area_code = models.CharField(max_length=3, db_column='AreaCode',
null=False, blank=False)
prefix = models.CharField(max_length=3, db_column='Prefix',
blank=True)
suffix = models.CharField(max_length=4, db_column='Suffix',
null=False, blank=False)
class Meta:
db_table = u'Phone'
app_label = u'testStuff'
db_tablespace = u'test'
class Room(models.Model):
id = models.AutoField(primary_key=True, db_column='id')
number = models.IntegerField(db_column='number', null=False,
blank=False)
building = models.CharField(max_length=5, db_column='Building',
null=False, blank=False)
type = models.CharField(max_length=1, db_column='Type',
null=False, blank=False)
campus = models.CharField(max_length=10, db_column='Campus',
null=False, blank=False)
phones = models.ManyToManyField(Phone, db_column='id', null=True)
class Meta:
db_table = u'Phone'
app_label = u'testStuff'
db_tablespace = u'test'
----------
Next, I dropped the existing tables in my mysql db, then ran
'syncdb'. The model tables were created, but not the intermediate
table. Adding phones & rooms are no problem, but I get an error when I
try to associate them, which states that the table 'Room_phones' does
not exist in the db. I could manually create a 'through' table, I
guess, but shouldn't Django have created my intermediate table along
with the primary ones? Thx for any help.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment