django integrityerror: duplicate key value violates unique constraint "django_content_type_pkey"

1.6k views Asked by At

I've been working on this project on my desktop, upon updating my local repo with the github repo, I tried to migrate the changes I had made on my desktop to the database (added fields). I'm not getting this error and im not sure why. Detail: key(id)=1 already exists. I've tried looking up solutions but could not find any accurate ones. Does anyone know how to solve this?

"django.db.utils.IntegrityError: duplicate key value violates unique 
constraint "django_content_type_pkey" DETAIL:  Key (id)=(1) already exists."
1

There are 1 answers

1
Jasonborn On

you can try this sql statement:SELECT setval('table name_id_seq', (SELECT MAX(id) FROM table name)+1)