Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

duplicate key value violates unique constraint "django_admin_log_pkey"

-- Enter the DB shell with `./manage.py dbshell`

-- Get latest ID
SELECT id FROM "django_admin_log" ORDER BY id DESC LIMIT 1;

-- Set the next value of the ID sequence to the result of the first query + 1
SELECT setval('django_admin_log_id_seq', LASTID + 1);

-- (replace `LASTID` with the result of the first query)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #duplicate #key #violates #unique #constraint
ADD COMMENT
Topic
Name
1+3 =