我正在使用Aldryn Newsblog和FAQ插件。 Django版本1.8.8,Django CMS 3.2.0。
我试图通过按"创建"来创建新的博客文章或常见问题解答。在工具栏中(图1)。
它弹出一个很好的向导来填充内容,但是当我实际提交它时,我得到了图像2中的错误:
" / cms_wizard / create /的DatabaseError 使用update_fields保存不会影响任何行。"。
堆栈追踪:
Environment:
Request Method: POST
Request URL: http://localhost:9000/cms_wizard/create/
Django Version: 1.8.8
Python Version: 2.7.10
Installed Applications:
('djangocms_admin_style',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_text_ckeditor',
'djangocms_ckeditor_filer',
'filer',
'easy_thumbnails',
'wwb',
'adminsortable2',
'aldryn_apphooks_config',
'aldryn_boilerplates',
'aldryn_categories',
'aldryn_common',
'aldryn_newsblog',
'aldryn_faq',
'aldryn_people',
'aldryn_reversion',
'aldryn_translation_tools',
'parler',
'reversion',
'sortedm2m',
'taggit',
'gunicorn')
Installed Middleware:
('cms.middleware.utils.ApphookReloadMiddleware',
'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.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
'djangocms_ckeditor_filer.middleware.ThumbnailMiddleware')
Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in inner
145. return func(*args, **kwargs)
File "/Library/Python/2.7/site-packages/cms/wizards/views.py" in dispatch
38. request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/formtools/wizard/views.py" in dispatch
237. response = super(WizardView, self).dispatch(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/django/views/generic/base.py" in dispatch
89. return handler(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/formtools/wizard/views.py" in post
300. return self.render_done(form, **kwargs)
File "/Library/Python/2.7/site-packages/formtools/wizard/views.py" in render_done
357. **kwargs)
File "/Library/Python/2.7/site-packages/cms/wizards/views.py" in done
148. instance = form_two.save()
File "/Library/Python/2.7/site-packages/aldryn_newsblog/cms_wizards.py" in save
112. body=content,
File "/Library/Python/2.7/site-packages/cms/api.py" in add_plugin
347. plugin.save()
File "/Library/Python/2.7/site-packages/djangocms_text_ckeditor/models.py" in save
47. super(AbstractText, self).save(*args, **kwargs)
File "/Library/Python/2.7/site-packages/cms/models/pluginmodel.py" in save
248. super(CMSPlugin, self).save(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save
734. force_update=force_update, update_fields=update_fields)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in save_base
762. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Library/Python/2.7/site-packages/django/db/models/base.py" in _save_table
831. raise DatabaseError("Save with update_fields did not affect any rows.")
Exception Type: DatabaseError at /cms_wizard/create/
Exception Value: Save with update_fields did not affect any rows.
Settings.py文件:
import os
gettext = lambda s: s
DATA_DIR = os.path.dirname(os.path.dirname(__file__))
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
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 = 'g67=r(8b)#=!x1^ddido=qp&9_pq=5&acs%u=xr_xe7t3uq70n'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
ROOT_URLCONF = 'myapp.urls'
WSGI_APPLICATION = 'myapp.wsgi.application'
LANGUAGE_CODE = 'en'
TIME_ZONE = 'Europe/Dublin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(DATA_DIR, 'media/')
STATIC_ROOT = os.path.join(DATA_DIR, 'static/')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'myapp', 'static'),
os.path.join(BASE_DIR, 'myapp', 'templates'),
)
SITE_ID = 1
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'wwb', 'templates'),
],
'OPTIONS': {
'debug': True,
'context_processors':
[
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.i18n',
'django.core.context_processors.debug',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.csrf',
'django.core.context_processors.tz',
'sekizai.context_processors.sekizai',
'django.core.context_processors.static',
'cms.context_processors.cms_settings',
'aldryn_boilerplates.context_processors.boilerplate',
],
'loaders':
[
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
]
}
},
]
MIDDLEWARE_CLASSES = (
'cms.middleware.utils.ApphookReloadMiddleware',
'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.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
'djangocms_ckeditor_filer.middleware.ThumbnailMiddleware'
)
INSTALLED_APPS = (
'djangocms_admin_style',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'cms',
'menus',
'sekizai',
'treebeard',
'djangocms_text_ckeditor',
#for uploading images to ckeditor
'djangocms_ckeditor_filer',
'filer',
'easy_thumbnails',
'wwb',
#for aldryn-blog and aldryn-faq
'adminsortable2',
'aldryn_apphooks_config',
'aldryn_boilerplates',
'aldryn_categories',
'aldryn_common',
'aldryn_newsblog',
'aldryn_faq',
'aldryn_people',
'aldryn_reversion',
'aldryn_translation_tools',
'parler',
'reversion',
'sortedm2m',
'taggit',
'gunicorn',
)
ALDRYN_BOILERPLATE_NAME = 'bootstrap3'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
THUMBNAIL_HIGH_RESOLUTION = True
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'easy_thumbnails.processors.scale_and_crop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters',
)
LANGUAGES = (
('en', gettext('en')),
)
CMS_TEMPLATES = (
('staticpage.html', 'Static page'),
)
CMS_PERMISSION = True
CMS_PLACEHOLDER_CONF = {
'carousel': {
'plugins': ['CMSCarouselPlugin']
},
'info section - image cycle': {
'plugins': ['ImageCyclePlugin']
}
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'HOST': 'localhost',
'NAME': 'project.db',
'PORT': '',
}
}
CKEDITOR_SETTINGS = {
'toolbar': 'Basic',
'extraPlugins': 'filerimage',
'removePlugins': 'image,flash',
}
但是,它可以通过主管理区域正常工作,并添加"新常见问题解答类别"通过向导也可以正常工作。
有什么想法吗?
答案 0 :(得分:1)
比较Aldryn常见问题解答(适用于你)和{Aldryn NewsBlog(不适合)的save()
的{{1}}方法,有一条线索可能是您设置了CMSWizard
1}}和WIZARD_CONTENT_PLUGIN
?常见问题解答使用这些设置,而新闻博客则没有,而是需要使用WIZARD_CONTENT_PLUGIN_BODY
djangocms-text-ckeditor
。
我确实看到你安装了TextPlugin
。我想知道你是否还没有为它进行迁移呢?
您是否可以在项目的其他地方使用普通djangocms-text-ckeditor
?
答案 1 :(得分:1)
所以答案是我需要为我的Django == 3.2.0版本使用djangocms-text-ckeditor> = 2.8.1。
谢谢@mkoistinen!