1

データベースを削除しました。

SyncDb を実行しました。

ダンプからロードしようとしています..-python manage.py loaddata dump.json。

Get-「<1062 キーの重複エントリ ''..」

「python manage.py reset contenttypes」を実行しました

しかし、取得-

 Error: Error: contenttypes couldn't be reset. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlreset contenttypes'. That's the SQL this command wasn't able to run.
The full error: (1217, 'Cannot delete or update a parent row: a foreign key constraint fails')

実行してみてください:

django.core インポート管理から

management.call_command("flush", verbosity=, interactive=False)

management.call_command("完全にリセット", "contenttypes", verbosity=, interactive=False)

management.call_command("loaddata", "full_test_data.json", verbosity=)

しかし、get- 構文エラーです。

python 2.7 を持っています。およびジャンゴ1.4

何か案は?

4

1 に答える 1

1

foreign_key_checksfalse を設定してみてください。

DATABASES = {
    'default': {
        # ...         
        'OPTIONS': {
            "init_command": "SET foreign_key_checks = 0;",
        },
    }
}

ただし、 --naturalオプションを指定して dumpdata コマンドを使用し、フィクスチャにハードコードされたコンテンツ タイプがないことを確認する必要があります。

于 2013-04-26T09:15:18.713 に答える