Django cms porting error (0) constraints

I have been following a tutorial on installing Django CMS but I am stuck on setting up Django CMS to work with Django, here:

http://django-cms.readthedocs.org/en/latest/how_to/install.html#configuring-your-project-for-django-cms

When I omit the "cms" from INSTALLED_APPS, the migration succeeds and my browser displays the default Django page.

However, when I add "cms" to INSTALLED_APS and run "python manage.py migrate", the migration fails, as you can see in the code below.

This doesn't work with an empty database, or starts after a successful migration I mentioned above.

I changed the order of INSTALLED_APPS, but it has no effect.

I reviewed the definition of "alter_unique_together" in:

site-packages/django/db/backends/schema.py

      

but can't figure out what's going on.

Help evaluate, provide any additional details.

Information

Project file structure

  • natureschoolssite
    • manage.py
    • MEDIA /
    • my.cnf
    • natureschoolssite /
      • models.py
      • settings.py
      • urls.py
      • wsgi.py
    • static /
    • Templates /
      • base.html
      • template_1.html
      • template_2.html

The output of "python manage.py migrate"

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)

      

Freeze Outline Output

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

      

Settings.py

# -*- 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/"

      

+3


source to share


1 answer


I had a similar problem with the Zinnia blog app. As a result, I just created the indexes that I want to remove migrations in the 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

      

In your case, it could be something like:



db=> create index on cms_page (publisher_is_draft, application_namespace);

      

Hope it helps!

+1


source







All Articles