我一直在关注Django CMS安装教程,但是在配置Django CMS以使用Django时遇到困难,在这里:
当我从INSTALLED_APPS中省略“cms”时,迁移成功,默认的Django页面显示在我的浏览器中。
但是,当我向INSTALLED_APS添加“cms”并运行“python manage.py migrate”时,迁移失败,如下面的代码所示。
无论是使用空数据库还是在我上面提到的成功迁移后运行它都会失败。
我已经改变了INSTALLED_APPS的顺序但是没有效果。
我在
中查看了“alter_unique_together”的定义site-packages/django/db/backends/schema.py
但无法理解失败的原因。
帮助表示赞赏,将提供所需的任何额外详细信息。
Operations to perform:
Synchronize unmigrated apps: treebeard, sekizai, djangocms_admin_style
Apply all migrations: sessions, admin, sites, auth, menus, contenttypes, cms
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sites.0001_initial... OK
Applying cms.0001_initial... OK
Applying cms.0002_auto_20140816_1918... OK
Applying cms.0003_auto_20140926_2347... OK
Applying cms.0004_auto_20140924_1038... OK
Applying cms.0005_auto_20140924_1039... OK
Applying cms.0006_auto_20140924_1110... OK
Applying cms.0007_auto_20141028_1559... OK
Applying cms.0008_auto_20150208_2149... OK
Applying cms.0008_auto_20150121_0059...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate
self.apply_migration(migration, fake=fake)
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 102, in apply_migration
migration.apply(project_state, schema_editor)
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 108, in apply
operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 282, in database_forwards
getattr(new_model._meta, self.option_name, set()),
File "/home/vagrant/.virtualenvs/natureschools/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 302, in alter_unique_together
", ".join(columns),
ValueError: Found wrong number (0) of constraints for cms_page(publisher_is_draft, application_namespace)
cffi==0.9.2
cmsplugin-filer==0.10.1
cryptography==0.9
Django==1.7.7
django-appconf==1.0.1
django-classy-tags==0.5
django-cms==3.1.0
django-filer==0.9.9
django-mptt==0.6.1
django-polymorphic==0.7.1
django-reversion==1.8.5
django-sekizai==0.7
django-treebeard==3.0
djangocms-admin-style==0.2.2
easy-thumbnails==2.2
enum34==1.0.4
html5lib==0.999
idna==1.1
ipaddress==1.0.7
MySQL-python==1.2.5
mysqlclient==1.3.6
ndg-httpsclient==0.4.0
Pillow==2.8.1
pyasn1==0.1.7
pycparser==2.13
pyOpenSSL==0.15.1
six==1.3.0
South==1.0.2
Unidecode==0.4.17
# -*- coding: utf-8 -*-
"""
Django settings for natureschoolssite project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
gettext = lambda s: s
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '6x9y_5)$$&$k&so_p5v=if+_4=f!z3%2almz%nha*%*r(vjm#w'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
SITE_ID = 1
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
'cms',
'djangocms_admin_style',
'django.contrib.admin',
'django.contrib.messages',
'django.contrib.sites',
'treebeard',
'menus',
'sekizai',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware'
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.static',
'sekizai.context_processors.sekizai',
'cms.context_processors.cms_settings',
)
ROOT_URLCONF = 'natureschoolssite.urls'
WSGI_APPLICATION = 'natureschoolssite.wsgi.application'
TEMPLATE_DIRS = (
# The docs say it should be absolute path: BASE_DIR is precisely one.
# Life is wonderful!
os.path.join(BASE_DIR, "templates"),
)
CMS_TEMPLATES = (
('template_1.html', 'Template One'),
('template_2.html', 'Template Two'),
)
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': '/var/www/natureschools/natureschoolssite/my.cnf',
},
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGES = [
('en-us', 'English'),
]
TIME_ZONE = 'GMT'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"
答案 0 :(得分:1)
我在Zinnia博客应用程序中遇到了类似的问题。我最终做的是我只是在Postgres shell中直接创建了迁移想要删除的索引:
db=> create index on zinnia_entry (slug, creation_date);
CREATE INDEX
db=> create index on zinnia_entry (status, creation_date, start_publication, end_publication);
CREATE INDEX
在你的情况下可能是这样的:
db=> create index on cms_page (publisher_is_draft, application_namespace);
希望它有所帮助!