Why does Postgres generate an already used PK value?
PostgreSQL will not try to insert duplicate values on its own, it is you (your application, ORM included) who does.  

It can be either a sequence feeding the values to the PK set to the wrong position and the table already containing the value equal to its nextval() - or simply that your application does the wrong thing.  The first one is easy to fix:

SELECT setval('your_sequence_name', (SELECT max(id) FROM your_table));


The second one means debugging.

Django (or any other popular framework) doesn't reset sequences on its own - otherwise we would have similar questions every other day.