Error: duplicate key value violates unique constraint

529 views
Skip to first unread message

Salima Begum

unread,
Sep 24, 2022, 1:46:15 AM9/24/22
to django...@googlegroups.com
Hi all,

When I am posting data in the server here we have an issue where the primary key already exists. For example, today I posted some data . I have the same issue. I solved the issue by deleting data from that particular table and then I am able to post data. Next day if I try to post data I am having the same issue with the primary key already exists. Why this is happening I am not able to understand.  On the server I am getting this issue where as in local I don't have any issue.
Please help me to understand why I am having this issue.
```
django.db.utils.IntegrityError: duplicate key value violates unique constraint "trades_trade_table_pkey"
DETAIL: Key (id)=(2) already exists
```
Thank you
~Salima

Shams Ulhaq

unread,
Sep 24, 2022, 1:57:14 AM9/24/22
to django...@googlegroups.com
Make an other constraints pk and your issue is solved django by default  make a pk as id 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMSz6bmxvY2f3caZbqvNG3ZaghriShCQV1pouvvOWmgx-wpgbA%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages