如何将应用程序添加到Django CMS 3.0.12并进行迁移?

时间:2015-04-07 18:58:12

标签: python django

我是Django和DjangoCMS的新手。我最近安装了DjangoCMS,并希望按照教程Tutorial 1Introduction to Plugins编写自己的应用程序。

经过一些研究和测试,我发现当我尝试运行其中一个命令时:

python manage.py migrate

or

python manage.py makemigrations polls

我最终遇到以下错误:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
    django.setup()
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
   app_config.import_models(all_models)
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
   self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/djangocms_text_ckeditor/models.py", line 14, in <module>
    from cms.models import CMSPlugin
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/cms/models/__init__.py", line 3, in <module>
    from .pagemodel import *  # nopyflakes
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/cms/models/pagemodel.py", line 20, in <module>
    from cms.models.placeholdermodel import Placeholder
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/cms/models/placeholdermodel.py", line 16, in <module>
    from cms.utils.placeholder import PlaceholderNoAction, get_placeholder_conf
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/cms/utils/placeholder.py", line 8, in <module>
    from sekizai.helpers import get_varname
  File "/home/username/folder/DjangoCMS/env/local/lib/python2.7/site-packages/sekizai/helpers.py", line 3, in <module>
    from django.template import VariableNode, Variable
ImportError: cannot import name VariableNode

我认为它特定于我在settings.py文件中设置的已安装应用程序,因为我一直在处理此错误,我发现大多数用于DjangoCMS的INSTALLED_APPS中设置的应用程序实际上都没有#39 ;必须安装我在本地运行网站。

INSTALLED_APPS = (
    'djangocms_admin_style',
    'djangocms_text_ckeditor',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.admin',
    'django.contrib.sites',
    'django.contrib.sitemaps',
    'django.contrib.staticfiles',
    'django.contrib.messages',
    'djangocms_style',
    'djangocms_column',
    'djangocms_file',
    'djangocms_flash',
    'djangocms_googlemap',
    'djangocms_inherit',
    'djangocms_link',
    'djangocms_picture',
    'djangocms_teaser',
    'djangocms_video',
    'cms',
    'menus',
    'sekizai',
    'reversion',
    'mptt',
    'south',
    'mywebsite',
    'polls'
)

查看堆栈我认为这个特殊错误与sekizai应用程序有关但是当我继续并且pip install django-sekizai时,我仍然在尝试迁移时遇到相同的错误。

2 个答案:

答案 0 :(得分:1)

所以我发现了这个问题。 DjangoCMS仅在使用Django 1.6版时才能正常工作,并且依赖于南迁移软件包/ app。

为了解决问题,请执行以下操作:

pip install django==1.6

还要确保使用正确的教程,您可以通过查看URL来查看。

到目前为止我注意到的事情,django 1.6中不存在 makemigrations :(

答案 1 :(得分:1)

我用Django == 1.9.7尝试了这个,如果你将django-sekizai升级到版本0.9.0,那么错误消失了。 所以只需将你的django-sekizai升级到你的Django版本的最新版本。

pip install django-sekizai==0.9.0