Django转储:模型不验证

Joh*_*nna 2 django dump django-models django-database

当我尝试使用此指令在Django中转储模型的数据时:

python manage.py dumpdata app> temp_data.json
Run Code Online (Sandbox Code Playgroud)

它给出以下错误:

Error: One or more models did not validate:
asset.authpermission: "codename": CharField cannot have a "max_length" greater than 255 when using "unique=True".
asset.djangocontenttype: "app_label": CharField cannot have a "max_length" greater than 255 when using "unique=True".
asset.djangocontenttype: "model": CharField cannot have a "max_length" greater than 255 when using "unique=True".
Run Code Online (Sandbox Code Playgroud)

问题是这些表是由django自动生成的.另外,我刚刚检查了数据库(mysql),字段是varchar(100).

怎么了 ?

rew*_*ten 6

那些表是由manage.py inspectdb右边生成的?然后,您不需要将django自己的模型包含到实际生成的模型中.只是删除任何模型开始auth,django,adminsite.

只需将相应的contrib应用程序包含在INSTALLED_APPS设置中即可,不会再出现错误.