【问题标题】:Creating plugin for Django-CMS为 Django-CMS 创建插件
【发布时间】:2013-09-09 22:48:48
【问题描述】:

我想我在尝试创建 django-cms 插件时搞砸了,现在我无法返回。该插件(称为 sbbplugin)似乎正在“工作”(它被显示)但每当我尝试发布该网站时,我都会收到以下错误:

DatabaseError at /admin/cms/page/18/publish/

relation "cmsplugin_sbbmodel" does not exist
LINE 1: ...id", "cmsplugin_sbbmodel"."cmsplugin_ptr_id" FROM "cmsplugin...
                                                             ^

我尝试删除插件,但我不能这样做,因为该页面未发布。我的插件没有模型或任何东西。此外,我无法通过单击删除从页面中删除插件。好像数据库坏了。由于我没有足够的经验知道您需要什么信息,如果您能给我进一步的指示,我将不胜感激。

更新:我认为问题在于我尝试使用已删除的模型(sbbmodel)。我应该尝试再次添加模型吗?如果是这样,我应该怎么做才能修复数据库?我是否必须为我的应用程序运行迁移?我什至必须将插件注册为应用程序吗?

Update2:所以我尝试再次添加模型并迁移应用程序,但出现以下错误:

CommandError: One or more models did not validate:
sbbplugin.sbbmodel: Accessor for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.
sbbplugin.sbbmodel: Reverse query name for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.
S.sbbmodel: Accessor for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.
S.sbbmodel: Reverse query name for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.

我不太明白,因为我从未指定外键。我认为这是因为我继承自 CMSPlugin。有什么帮助吗?

【问题讨论】:

    标签: database django plugins django-models django-cms


    【解决方案1】:

    我终于修好了。首先,我删除了为插件创建的每个文件。然后我删除了保存在数据库中的插件的每个实例。不幸的是,这并没有解决问题,即使在重新启动服务器后我仍然遇到同样的错误。

    诀窍是进入 phpPgAdmin 并选择所有表而不是选择“正确”。它没有告诉我到底是什么问题,但之后一切又恢复了正常。因此,如果您以某种方式遇到同样的问题,只需自动“更正”您的数据库即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-31
      • 2011-06-12
      • 2015-03-12
      • 1970-01-01
      • 2014-11-25
      • 2011-06-23
      • 1970-01-01
      • 2017-03-12
      相关资源
      最近更新 更多