7👍
Seems that django dumpdata dumped fixtures in wrong order. Look in json file to check whether product
with id: 1
is present there. If, as I suppose, this is true, use some more sophisticated tools to dump data, for example django-fixture-magic
Alternatively, you might want to delete all integrity constraints by means of db engine just before upload and try to recreate them right after, but this is somewhat risky if some integrity errors will be present.
For PostgreSQL, consult this thread to know how to get your tables definitions. In MySQL it would be something like follows:
$ mysqldump --no-data -utest django auth_user_user_permissions
CREATE TABLE `auth_user_user_permissions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`permission_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`,`permission_id`),
KEY `auth_user_user_permissions_403f60f` (`user_id`),
KEY `auth_user_user_permissions_1e014c8f` (`permission_id`),
CONSTRAINT `user_id_refs_id_dfbab7d` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`),
CONSTRAINT `permission_id_refs_id_67e79cb` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Following part should work for oracle, postgre and mysql
> alter table `auth_user_user_permissions` drop foreign key `user_id_refs_id_dfbab7d`;
Query OK, 0 rows affected (0.97 sec)
Records: 0 Duplicates: 0 Warnings: 0
> alter table `auth_user_user_permissions` add CONSTRAINT `user_id_refs_id_dfbab7d` FOREIGN KEY (`user_id`) references `auth_user` (`id`);
Query OK, 0 rows affected (0.95 sec)
Records: 0 Duplicates: 0 Warnings: 0
👤alko
Source:stackexchange.com