django-multitenant icon indicating copy to clipboard operation
django-multitenant copied to clipboard

Duplicate Constraint fails when I try to save model on Admin Panel

Open Alihassanc5 opened this issue 1 year ago • 1 comments

I am getting this error when I change the tenant and save the model through admin panel:

image

How can I resolve this error?

Alihassanc5 avatar Jun 18 '24 17:06 Alihassanc5

Check to make sure the postgresql sequence that was created to add an ID for that table is set correctly and the next ID is Max(id)+1

Or it could be that you tried to update the id manually.

You can reset it using the following: SELECT setval('tablename_id_seq', (SELECT COALESCE(max(id),0)+1 FROM "tablenames"), false);

andyp05 avatar Jun 18 '24 18:06 andyp05