Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
安装django.contrib.comments应用程序后无法同步我的django数据库_Django_Django Models_Django Fluent - Fatal编程技术网

安装django.contrib.comments应用程序后无法同步我的django数据库

安装django.contrib.comments应用程序后无法同步我的django数据库,django,django-models,django-fluent,Django,Django Models,Django Fluent,我有一个错误: CommandError: One or more models did not validate: comments.comment: Accessor for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'. co

我有一个错误:

CommandError: One or more models did not validate:
comments.comment: Accessor for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
comments.comment: Reverse query name for field 'content_type' clashes with related field 'ContentType.content_type_set_for_comment'. Add a related_name argument to the definition for 'content_type'.
comments.comment: Accessor for field 'site' clashes with related field 'Site.comment_set'. Add a related_name argument to the definition for 'site'.
comments.comment: Accessor for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
comments.comment: Reverse query name for field 'user' clashes with related field 'User.comment_comments'. Add a related_name argument to the definition for 'user'.
comments.commentflag: Accessor for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.
comments.commentflag: Reverse query name for field 'user' clashes with related field 'User.comment_flags'. Add a related_name argument to the definition for 'user'.
起初,我安装了一个名为“django_comments”的新应用程序,并同步了我的数据库。但是 在我决定使用需要django.contrib.comments的django fluent注释之后。因此,我将django.contrib.comments替换为django_注释

在我同步数据库之后,我的django项目由于上述错误而崩溃

所以,请帮助解决这个问题或给我一些建议

谢谢你的建议


PS:我尝试使用另一个虚拟环境创建新项目,并将mysql更改为sqlite3,但仍然存在此错误。

我解决了我的问题。这是因为我忘了删除旧应用程序django_评论中我模型中的所有导入内容。所以现在一切都很好

你使用什么版本的Django?您是否自定义了站点或用户模型?根据错误,这与您的数据库无关,只是Django模型没有验证(每次运行runserver/syncdb,…命令时,它都会验证模型)抱歉,但我发现了我的错误),正如您在my models.py中所说的那样。有一些来自老应用程序django_评论的导入,所以在我删除这一行之后,一切都开始工作了。谢谢你的帮助。对于这样的错误,有奇怪的错误消息。好吧,我想这对以后的其他Django用户可能有用,即使Django.contrib.comments现在不推荐:)