그래서 다음 표를 작성하여 테스트했습니다.Django의 inspectdb는 ManyToManyField를 사용하지 않습니다.
# Dump of table driverclass
# ------------------------------------------------------------
CREATE TABLE `driverclass` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# Dump of table event
# ------------------------------------------------------------
CREATE TABLE `event` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# Dump of table driver
# ------------------------------------------------------------
CREATE TABLE `driver` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# Dump of table driver_driverclass_event
# ------------------------------------------------------------
CREATE TABLE `driver_driverclass_event` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`driver_id` int(11) unsigned DEFAULT NULL,
`event_class_id` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `driver_id` (`driver_id`),
KEY `event_class_id` (`event_class_id`),
CONSTRAINT `driver_driverclass_event_ibfk_2` FOREIGN KEY (`event_class_id`) REFERENCES `driverclass_event` (`id`),
CONSTRAINT `driver_driverclass_event_ibfk_1` FOREIGN KEY (`driver_id`) REFERENCES `driver` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
# Dump of table driverclass_event
# ------------------------------------------------------------
CREATE TABLE `driverclass_event` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`event_id` int(11) unsigned DEFAULT NULL,
`driverclass_id` int(11) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `event_id` (`event_id`),
KEY `driverclass_id` (`driverclass_id`),
CONSTRAINT `driverclass_event_ibfk_2` FOREIGN KEY (`driverclass_id`) REFERENCES `driverclass` (`id`),
CONSTRAINT `driverclass_event_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `event` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ManyToManyField
의 관계이어야합니다. 그러나, Djangos
inspectdb
은 ForeignKeys 톤을 가진 5 개의 모델로 보았다. Djangos
inspectdb
은 ManyToManyFields를 고려하지 않습니까, 아니면 내 databasemodel이 잘못 되었습니까?
무엇이 출력 되었습니까? – Ngenator
서로 외래 키가있는 5 개의 테이블 – Martol1ni