- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在我的 django-cms 网站中,我在通过管理界面发布页面时遇到了一些问题。在堆栈跟踪下方:
DEBUG 2013-06-07 14:09:31,562 util 32222 140056576640768 (0.000) SELECT DISTINCT "menus_cachekey"."key" FROM "menus_cachekey" WHERE "menus_cachekey"."site" = 1 ; args=(1,)
DEBUG 2013-06-07 14:09:31,565 util 32222 140056576640768 (0.000) DELETE FROM "menus_cachekey" WHERE "menus_cachekey"."site" = 1 ; args=(1,)
DEBUG 2013-06-07 14:09:31,570 util 32222 140056576640768 (0.001) INSERT INTO "cms_page" ("created_by", "changed_by", "parent_id", "creation_date", "changed_date", "publication_date", "publication_end_date", "in_navigation", "soft_root", "reverse_id", "navigation_extenders", "published", "template", "site_id", "login_required", "limit_visibility_in_menu", "level", "lft", "rght", "tree_id", "publisher_is_draft", "publisher_public_id", "publisher_state") VALUES (E'roberto', E'roberto', NULL, E'2013-06-07 12:09:31.567872+00:00', E'2013-06-07 12:09:31.567989+00:00', E'2013-06-07 12:09:26.553334+00:00', NULL, false, false, NULL, NULL, true, E'unicms/departments_and_groups/department_detail.html', 1, false, NULL, 0, 1, 2, 9, false, 9, 0) RETURNING "cms_page"."id"; args=(u'roberto', u'roberto', None, u'2013-06-07 12:09:31.567872+00:00', u'2013-06-07 12:09:31.567989+00:00', u'2013-06-07 12:09:26.553334+00:00', None, False, False, None, None, True, u'unicms/departments_and_groups/department_detail.html', 1, False, None, 0, 1, 2, 9, False, 9, 0)
ERROR 2013-06-07 14:09:31,571 base 32222 140056576640768 Internal Server Error: /admin/cms/page/9/change-status/
Traceback (most recent call last):
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 202, in inner
return view(request, *args, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/utils/decorators.py", line 25, in _wrapper
return bound_func(*args, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/views/decorators/http.py", line 41, in inner
return func(request, *args, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/utils/decorators.py", line 21, in bound_func
return func(self, *args2, **kwargs2)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/cms/admin/pageadmin.py", line 1062, in change_status
success = method()
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/cms/models/pagemodel.py", line 419, in publish
public_page.save()
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/cms/models/pagemodel.py", line 367, in save
super(Page, self).save(**kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/mptt/models.py", line 696, in save
super(MPTTModel, self).save(*args, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/models/base.py", line 546, in save
force_update=force_update, update_fields=update_fields)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/cms/models/pagemodel.py", line 384, in save_base
ret = super(Page, self).save_base(*args, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/models/base.py", line 650, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/models/manager.py", line 215, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/models/query.py", line 1661, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 937, in execute_sql
cursor.execute(sql, params)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/backends/util.py", line 41, in execute
return self.cursor.execute(sql, params)
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 56, in execute
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
File "/home/roberto/.virtualenvs/ve_news2_app/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 54, in execute
return self.cursor.execute(query, args)
IntegrityError: duplicate key value violates unique constraint "cms_page_publisher_public_id_key"
部门模型很简单
class Department(models.Model):
research_area = models.ManyToManyField('research_area.ResearchArea', blank=True,
related_name='departments') # many-to-many
products = models.ManyToManyField('products_activities.Product', blank=True, related_name="departments")
employees = models.ManyToManyField('staff.Person', through='department.PersonDepartmentMembership',
related_name='departments') # TODO WARNINGS
research_groups = models.ManyToManyField('group.Group', blank=True, related_name='departments',
through="department.GroupDepartmentMembership")
page = models.OneToOneField(Page, blank=True, related_name='department', null=True)
name = models.CharField(_('department name'), max_length=50, default=_('Department name'))
description = models.TextField(_('department description'))
logo = models.ImageField(upload_to='img/departments')
address = models.CharField(_('office address'), max_length=255)
post_address = models.CharField(_('post address'), max_length=255)
telephone = PhoneNumberField(blank=True, null=True)
fax = PhoneNumberField(blank=True, null=True)
email = models.EmailField()
class Meta:
permissions = (
('view_department', _('View department')),
)
def __unicode__(self):
return self.name
def get_absolute_url(self):
return reverse('pages-details-by-slug', kwargs={'slug': self.page.get_slug('en')})
并非所有页面都受此问题影响。在我的 cms 中,我设置了一个自动页面创建系统。当用户创建部门时,会设置一个新页面。
@receiver(post_save, sender=Department)
def _on_save_department_create_link_to_page(sender, instance, created, **kwargs):
from cms.api import assign_user_to_page, add_plugin, publish_page
if created: # create department Page
from cms.api import create_page
instance.page = create_page(
title=instance.name,
language='en',
published=False,
template=settings.CMS_TEMPLATE_DEPARTMENT[0],
)
# add some plugins...
editors = instance.employees.filter(cmsuser__groups__name__exact='web')
for e in editors:
assign_user_to_page(instance.page, e)
instance.page.save()
我在网上找到了some blog article指出他的可能是由于连续的南迁。我几乎不怀疑,因为我在没有应用任何数据迁移的情况下也有错误。
非常感谢任何反馈!提前致谢:-)
最佳答案
由于升级 django-cms 时审核的运行方式发生了变化,您需要运行:
python manage.py cms moderator on
参见 http://docs.django-cms.org/en/2.4.0/advanced/cli.html#moderation-commands了解更多信息。
如果您仍在为某些页面而苦苦挣扎,仍然会出现该约束错误,您将需要打开一个 Django shell:
python manage.py dbshell
然后用SQL删除问题
delete from cms_page where publisher_public_id=79;
关于python - 由于 "IntegrityError: duplicate key value violates unique constraint",无法在 django-cms 上发布页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16985054/
我有一个内部表,里面有 108 个条目。从 9 到 9 个条目重复条目,我想删除这些重复项。由于它们完全相同,我使用了 delete adjacent duplicates from itab com
在 Team Foundation Server (TFS) 中链接两个工作项 (WI) 时,在什么情况下将“Duplicate”和“Duplicate Of”区分为“链接类型”是有意义的? 如何处理
ld: duplicate symbol _velocityX in \ /Users/Student/Library/Developer/Xcode/DerivedData/finalproject
我使用 PHP 和 Mysql。 此 SQL 有效: INSERT INTO products (id, title, description) VALUES (10, 'va
我有一个大数据框 (120000x40),我尝试在每一行中找到重复项并显示它们。这就是我的尝试: 创建数据框 import pandas as pd df = pd.DataFrame({'col1'
我是 mySQL 和 PHP 的新手,请多多包涵。 如果我的查询有重复字段,我该如何做到这一点,检索到的数据将具有重复查询字段的重复数据。 一个例子是这样的: 查询 id = 34, 54, 21,
我一直遇到这个错误,但我无法理解它,因为它提示一个值恰好出现一次。 Exception in thread "main" java.lang.IllegalStateException: Duplic
我有一个带有 Vuejs 和 Laravel 的 Web 应用程序 我想使用 CKEditor 5 我安装了依赖项 npm install --save @ckeditor/ckeditor5-vue
我有一个包含以下数据的 csv 文件: Id,Name,Type,date 1,name1,employee,25/04/2017 2,name2,contrator,26/04/2017 3,nam
import CKEditor from '@ckeditor/ckeditor5-react'; import ClassicEditor from '@ckeditor/ckeditor5-bui
表定义: CREATE TABLE PositionalDataNGS ( Date DATE, Time TIME(3) , X FLOAT(5), Y FLOAT(5), D FLOAT(5) ,
我目前正在做一个项目,我要处理数以千计的数据包。现在,我记录每个数据包的 IP 和 MAC 地址以及一些其他信息。为了存储所有这些,我使用 MySQL 并且我的脚本是用 Node.js 编写的。目前我
I am using MySQL 5.1.56, MyISAM. My table looks like this:我使用的是MySQL 5.1.56,MyISAM。我的桌子是这样的: CR
我是新来的,对 SQL 比较陌生。我有一个类似这样的表: [Pk], [Case_No], [Status], [Open_Date], [Close_Date], [Case_Age], [Repo
为什么会收到此警告? warning No duplicate props allowed react/jsx-no-duplicate-props# 它显示的是第28行,但没有使用 Prop 。 最
是否有任何函数或方法可以在 python 2.7 中递归实现此目的? Input : ['and', ['or', 'P', '-R', 'P'], ['or', '-Q', '-R', 'P']]
我正在分析 hadoop 中的数据。有一些重复条目,其中 A、B 列重复,而 C 列不同。我想要做的是仅识别 A、B 重复项,然后为每个重复项打印出 C 列的不同值。 示例数据: row, data
您好,感谢阅读并可能对我有所帮助 我的问题的简要说明: 我正在将数据从一个 Firebird 数据库复制到另一个(称为 V14),并且我正在使用 IBExpert 来执行此操作。这些表的名称相同并且具
我想制作一张很像下面的图片: 我想使用 seaborn 使图表看起来漂亮,并让我自己以后更容易使用 facetgrids(我有十个不同的数据集,我想在同一个图表中显示。) 我在 seaborn 中找到
我在两列“user_id”和“project_id”上有一个复合唯一键。 当我尝试对单行或多行运行 DELETE 查询时,出现错误。 ERROR 1062: 1062: Duplicate entry
我是一名优秀的程序员,十分优秀!