I am having a problem creating a foreign key in my table. The foreign key table is:
CREATE TABLE `main_app_provider` (
`provider` varchar(100) NOT NULL DEFAULT '',
`provider_slug` varchar(100) DEFAULT NULL,
PRIMARY KEY (`provider`),
KEY `main_app_provider_75a6f163` (`provider_slug`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
If I do the generic provider = models.ForeignKey('main_app.Provider') I get an errno:150. How would I add a field in django with the exact criteria defined in provider?
Use
to_fieldto specify the field that Django should use as the primary key.