IntegrityError: Duplicate entry for key 'publisher_public_id'
See original GitHub issueI am unable to publish a page. Not sure what’s causing this issue.
Here’s the stack trace:
Environment:
Request Method: GET
Request URL: en/admin/cms/page/11/en/publish/
Django Version: 1.6.5
Python Version: 2.7.7
Installed Applications:
('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',
'filer',
'easy_thumbnails',
'cmsplugin_cascade',
'cmsplugin_filer_file',
'cmsplugin_filer_folder',
'cmsplugin_filer_image',
'cmsplugin_filer_teaser',
'cmsplugin_filer_video',
'cms',
'mptt',
'menus',
'south',
'sekizai',
'djangocms_style',
'djangocms_column',
'djangocms_file',
'djangocms_flash',
'djangocms_googlemap',
'djangocms_inherit',
'djangocms_link',
'djangocms_picture',
'djangocms_teaser',
'djangocms_video',
'reversion',
'foo',
'django_extensions')
Installed Middleware:
('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.doc.XViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware')
Traceback:
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
198. return view(request, *args, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/transaction.py" in inner
431. return func(*args, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/reversion/revisions.py" in do_revision_context
300. return func(*args, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/cms/admin/pageadmin.py" in publish_page
1049. published = page.publish(language)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/cms/models/pagemodel.py" in publish
572. public_page.save()
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/cms/models/pagemodel.py" in save
455. super(Page, self).save(**kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/mptt/models.py" in save
717. super(MPTTModel, self).save(*args, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/models/base.py" in save
545. force_update=force_update, update_fields=update_fields)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/cms/models/pagemodel.py" in save_base
473. ret = super(Page, self).save_base(*args, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/models/base.py" in save_base
573. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/models/base.py" in _save_table
654. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/models/base.py" in _do_insert
687. using=using, raw=raw)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/models/manager.py" in _insert
232. return insert_query(self.model, objs, fields, **kwargs)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/models/query.py" in insert_query
1514. return query.get_compiler(using=using).execute_sql(return_id)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
903. cursor.execute(sql, params)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/backends/util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute
124. return self.cursor.execute(query, args)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute
205. self.errorhandler(self, exc, value)
File "/home/foo/.virtualenvs/foo/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler
36. raise errorclass, errorvalue
Exception Type: IntegrityError at /en/admin/cms/page/11/en/publish/
Exception Value: (1062, "Duplicate entry '11' for key 'publisher_public_id'")
Any help would be appreciated. Thanks!
Issue Analytics
- State:
- Created 9 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
IntegrityError: (1062, Duplicate entry for key) - Stack Overflow
It sounds like a foreign key check has failed. Where is content_type_id being used as a foreign key? – Jared. Sep 6, 2011...
Read more >IntegrityError: Duplicate entry for key 'publisher_public_id' #3274
I am unable to publish a page. Not sure what's causing this issue. Here's the stack trace: Environment: Request Method: GET Request URL: ......
Read more >Getting django.db.utils.IntegrityError: (1062, "Duplicate entry ...
utils. IntegrityError: (1062, "Duplicate entry '' for key ''") while creating Model instance in Django. I am getting the error even though I...
Read more >Error IntegrityError 1062 Duplicate entry 1-1-1 for key CSID
I have a model with a unique_together defined for 3 fields to be unique together: class MyModel(models.Model): clid = models.
Read more >mysql - 1062 Duplicate entry but there are no duplicates?
Dealing with duplicates on insert: If you try INSERT a duplicate values for a primary key (or a unique index) you will always...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello.
We’ve experienced this sporadically in recent weeks in Django 1.7, Django-CMS 3.1. Unfortunately, it can basically bring a site down due to unhandled exceptions in
cms.api.get_page_draft
.I’ve written a Django management command (tested on Python 2.7, Django 1.8.8, Django-CMS 3.2.0) to fix broken
cms_page.publisher_public_id
columns:Note that when it’s looking for the draft equivalent of a non-draft page, if it can’t find it from the
publisher_public_id
foreign key, it assumes the draft page id will be one less than the non-draft page id. This may not necessarily be the case if successive draft pages were created without non-draft equivalents, and therefore could mess up thecms_page
table. Use with caution.I’ve really only posted this here to demonstrate that this issue (at least in Django 1.7, Django-CMS 3.1) hasn’t gone away, and is serious enough for us to have had to come up with this management command.
Unfortunately, the issue is intermittent and I cannot reproduce the problem (otherwise, I’d run it through a debugger and try to provide better information).
I experienced the same on Django 1.8.9 / Django-CMS 3.2.0 / Postgres 9.1
The management command helped! Thanks a bunch @mikemcgowan