can't publish page on django-cms due to "IntegrityError: duplicate key value violates unique constraint" can't publish page on django-cms due to "IntegrityError: duplicate key value violates unique constraint" postgresql postgresql

can't publish page on django-cms due to "IntegrityError: duplicate key value violates unique constraint"


Becuse of the change in how moderation runs when upgrading django-cms you'll need to run:

python manage.py cms moderator on

See http://docs.django-cms.org/en/2.4.0/advanced/cli.html#moderation-commands for more info.

If you're still struggling with some of the pages still giving that constraint error you'll need to open a django shell:

python manage.py dbshell

And then delete the problem with SQL

delete from cms_page where publisher_public_id=79;


There's a constraint in your database table cms_page that's called cms_page_publisher_public_id_key. A constraint can specify many things, but is usually used to keep values unique. In your case it seems to be something with uniqueness too:

duplicate key value violates unique constraint

In your model I can't see anything you specified as unique, but maybe you changed your code over time and forgot to change your database table accordingly?

Check what your table cms_page looks like in the database and what the constraint cms_page_publisher_public_id_key exaclty does. Then you'll probably find the cause.