Django 拒绝运行,抛出 CommandError
Posted
技术标签:
【中文标题】Django 拒绝运行,抛出 CommandError【英文标题】:Django refusing to run, throwing CommandError 【发布时间】:2016-10-26 09:46:14 【问题描述】:在我的服务器变砖后我不得不恢复备份,现在 Django 不断抛出系统检查命令错误。
account.Customer.country: (fields.E300) Field defines a relation with model 'Country', which is either not installed, or is abstract.
account.Customer.state: (fields.E300) Field defines a relation with model 'State', which is either not installed, or is abstract.
account.Customer.user: (fields.E304) Reverse accessor for 'Customer.user' ***es with reverse accessor for 'Customer.user'.
HINT: Add or change a related_name argument to the definition for 'Customer.user' or 'Customer.user'.
account.Customer.user: (fields.E305) Reverse query name for 'Customer.user' ***es with reverse query name for 'Customer.user'.
HINT: Add or change a related_name argument to the definition for 'Customer.user' or 'Customer.user'.
account.CustomerNote.author: (fields.E304) Reverse accessor for 'CustomerNote.author' ***es with reverse accessor for 'CustomerNote.author'.
HINT: Add or change a related_name argument to the definition for 'CustomerNote.author' or 'CustomerNote.author'.
account.EmailChangeRequest.user: (fields.E304) Reverse accessor for 'EmailChangeRequest.user' ***es with reverse accessor for 'EmailChangeRequest.user'.
HINT: Add or change a related_name argument to the definition for 'EmailChangeRequest.user' or 'EmailChangeRequest.user'.
account.SecurityAnswer.user: (fields.E304) Reverse accessor for 'SecurityAnswer.user' ***es with reverse accessor for 'SecurityAnswer.user'.
HINT: Add or change a related_name argument to the definition for 'SecurityAnswer.user' or 'SecurityAnswer.user'.
account.UserSession.user: (fields.E304) Reverse accessor for 'UserSession.user' ***es with reverse accessor for 'UserSession.user'.
HINT: Add or change a related_name argument to the definition for 'UserSession.user' or 'UserSession.user'.
customer.Customer.user: (fields.E304) Reverse accessor for 'Customer.user' ***es with reverse accessor for 'Customer.user'.
HINT: Add or change a related_name argument to the definition for 'Customer.user' or 'Customer.user'.
customer.Customer.user: (fields.E305) Reverse query name for 'Customer.user' ***es with reverse query name for 'Customer.user'.
HINT: Add or change a related_name argument to the definition for 'Customer.user' or 'Customer.user'.
customer.CustomerNote.author: (fields.E304) Reverse accessor for 'CustomerNote.author' ***es with reverse accessor for 'CustomerNote.author'.
HINT: Add or change a related_name argument to the definition for 'CustomerNote.author' or 'CustomerNote.author'.
security.EmailChangeRequest.user: (fields.E304) Reverse accessor for 'EmailChangeRequest.user' ***es with reverse accessor for 'EmailChangeRequest.user'.
HINT: Add or change a related_name argument to the definition for 'EmailChangeRequest.user' or 'EmailChangeRequest.user'.
security.SecurityAnswer.user: (fields.E304) Reverse accessor for 'SecurityAnswer.user' ***es with reverse accessor for 'SecurityAnswer.user'.
HINT: Add or change a related_name argument to the definition for 'SecurityAnswer.user' or 'SecurityAnswer.user'.
security.UserSession.user: (fields.E304) Reverse accessor for 'UserSession.user' ***es with reverse accessor for 'UserSession.user'.
HINT: Add or change a related_name argument to the definition for 'UserSession.user' or 'UserSession.user'.
这个构建和数据库以前工作过。我检查了 settings.py 并安装了它抱怨的应用程序。此外,related_name 错误似乎是在引用它们自己。
我尝试使用django.contrib.contenttypes.management
模块中的update_all_contenttypes
方法清除内容类型并重新填充它们。该表现在似乎是正确的,但仍然出现这些错误。
【问题讨论】:
【参考方案1】:好的,在我发布这个之后我就明白了。在项目重组之前,我有一些流氓models.pyc
文件,它们定义了相同的模型但在不同的应用程序中。清除所有这些文件解决了这个问题。我猜我需要在我的部署过程中加入这部分内容。
【讨论】:
以上是关于Django 拒绝运行,抛出 CommandError的主要内容,如果未能解决你的问题,请参考以下文章
mysqldump 抛出“拒绝访问”错误,但仅在通过 logrotate 运行时?
我在运行查询时启动了 RDS SQL Server(SQL Server Web 版)并抛出了权限被拒绝错误
作为 Azure 应用服务运行时,UserPrincipal.DisplayName 抛出 COMException“访问被拒绝”,在本地开发笔记本电脑上工作正常
网络调用抛出 IO 异常并且在 android 中拒绝连接在 android 设备中不起作用
在 docker-compose 中运行 Django 应用程序:与 postgres db 的连接第一次拒绝但之后可以工作