Hi All,
When I run manage.py sqlall test, I get the proper MySQL create
statements for my models, (Phone,Room).
Room has a ManyToManyField(Phone) field, so I also get the proper
intermediate Room_phones table:
BEGIN;
CREATE TABLE `Phone` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY , blah, blah
);
CREATE TABLE `Room_phones` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`room_id` integer NOT NULL,
`phone_id` integer NOT NULL,
UNIQUE (`room_id`, `phone_id`)
);
ALTER TABLE `Room_phones` ADD CONSTRAINT `phone_id_refs_id_61361b28`
FOREIGN KEY (`phone_id`) REFERENCES `Phone` (`id`);
CREATE TABLE `Room` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY , blah, blah
);
ALTER TABLE `Room_phones` ADD CONSTRAINT `room_id_refs_id_71507c04`
FOREIGN KEY (`room_id`) REFERENCES `Room` (`id`);
COMMIT;
models.py contains:
class Phone(models.Model):
type = models.CharField(max_length=1, db_column='Type',
null=False, blank=False)
...
class Room(models.Model):
...
phones = models.ManyToManyField(Phone)
manage.py syncdb doesn't create the Room_phones table though. Just the
Room and Phone. I thought it would create it automagically, even
though I don't have a model in models.py for it?? I'm working with
MySQL, the db engine is set to InnoDB. When I put the intermediary
table model explicitly in models.py and use the 'through' clause on
the ManyToManyField, there is no problem, syncdb works perfectly. I
can do this, but ...
TIA, Brian
--
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en.