2013-04-26 88 views
1

已删除我的数据库。django重置内容类型不匹配

已经运行SyncDb。

试图从转储加载..-蟒蛇manage.py loaddata dump.json。

的Get- “< 1062重复条目 '' 的关键。”

已经运行 “蟒蛇manage.py重置contentypes”

但GET-

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( “冲洗”,冗长=,交互式=假)

management.call_command( “完全复位”, “CONTENTTYPES”,冗长=,交互式=假)

management.call_command( “loaddata”, “full_test_data.json”,冗长=)

但是GET-语法错误。

有python 2.7。和Django 1.4

任何想法?

回答

1

尝试设置foreign_key_checks假,

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

但是你一定要尝试使用dumpdata命令与--natural选项,以确保没有硬编码的内容类型的电脑灯。

+0

不幸的是没有工作。是的,下次我做一个dumpdata我会用-natural。但现在有点迟到了:-( – kingRauk 2013-04-26 09:24:55