I had this issue that came up when I changed my workflow with regards to the website. I migrated the site and DB and carried on coding. After a while I was getting ready to move the development site to production and found I could not make changes on some of the applications within the site. It was throwing up the following error.
1duplicate key value violates unique constraint "django_admin_log_pkey"
After a bit of searching, I found the solution to my problem. There is a mismatch between the admin log ID and the admin log sequence ID. For me, the admin log ID was set at 407 and the sequence ID was at 377
1SELECT id FROM "django_admin_log" ORDER BY id DESC LIMIT 1;
As I say, my one was set to 407. So now we need to set the next number in the sequence to be correct.
1SELECT setval('django_admin_log_id_seq', <LASTID> + 1);
So, in the above query I had '407' in place of '<LASTID>'. Running this query will update the sequence ID to be correct and fixes the error
Comments