我收到以下错误:
IntegrityError: duplicate key value violates unique constraint "users_userprofile_pkey"
我正在从 MySQL 迁移到 Postgres,所以我使用以下方法从 MySQL 数据库中转储数据:
python2.7 manage.py dumpdata --indent=4 --natural > dump.json
当我尝试将 dump.json 加载到 Postgresql 数据库时出现错误:
python manage.py loaddata dump.json
我的用户/模型中有以下信号:
post_save.connect(create_user_profile, sender=User, dispatch_uid="user_create_profile")
post_save.connect(create_api_key, sender=User, dispatch_uid="user_create_api_key")
最佳答案
我不得不注释掉 post_save 信号,然后执行加载数据。
关于python - 切换到 Postgres 时 Django 加载数据中的 IntegrityError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11876530/