【问题标题】:How to start a django cms project如何启动 django cms 项目
【发布时间】:2010-12-14 10:39:20
【问题描述】:

我决定看看 django-cms。查看文档后,我使用

克隆了存储库
git clone https://github.com/divio/django-cms.git

然后我使用安装它

sudo python setup.py install

我已经安装了 django 1.2.3。我移动到example 目录并运行syncdb,它创建了以下表格:

Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_admin_log
Creating table django_site
Creating table sampleapp_category
Creating table sampleapp_picture
Creating table south_migrationhistory



You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes...

我们可以清楚地看到 cms 表没有创建。我在运行服务器和浏览http://localhost:8000/时显然遇到了这个问题@

DatabaseError: no such table: cms_page

我查看了文档,发现我符合有关版本的要求,但很明显,我做错了。任何帮助将不胜感激。

【问题讨论】:

  • 您项目的设置文件中是否启用了该应用?我认为这很可能是问题所在。

标签: python django django-cms


【解决方案1】:

django-cms 使用South 进行数据库迁移。 South 处理的模型不会使用syncdb 同步到数据库。你必须使用manage.py migrate

由于您没有来自 django-cms 的任何表和数据要迁移,因此更快的解决方案是这个过程:

  • 在您的INSTALLED_APPS 中注释掉'south'
  • 运行manage.py syncdb(这将从django-cms创建所有表)
  • 在您的INSTALLED_APPS 中重新启用南
  • 运行manage.py migrate --fake

下次更新 django-cms 时,您可以运行 manage.py migrate 来更新您的数据库表。

【讨论】:

  • 是的,我遵循了这一点,因为我已经将南用于其他项目。我认为问题在于伪造迁移并且之后不使用migrate --all
【解决方案2】:

您是否将'cms' 放入INSTALLED_APPS 放入settings.py? Django-CMS 还需要安装menuspublishermptt 以及一些中间件。 This is some nice to read documentation就可以了!

【讨论】:

  • 感谢您的回答,我也完成了该教程。我没有触及示例中的 settings.py,它包含 cms、菜单、发布者和 mptt,我都可以在 python shell 中导入。
【解决方案3】:

一般来说,如果没有创建表,应用程序本身可能会出现一些错误: 尝试运行 Django shell 并从应用程序中导入模型:

python manage.py shell

>>> from csm import models

并检查您是否获得回溯。

希望这能有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-23
    • 2017-02-22
    • 1970-01-01
    相关资源
    最近更新 更多