Django: IntegrityError during Many To Many add()
问题 We run into a known issue in django: IntegrityError during Many To Many add() There is a race condition if several processes/requests try to add the same row to a ManyToManyRelation. How to work around this? Envionment: Django 1.9 Linux Server Postgres 9.3 (An update could be made, if necessary) Details How to reproduce it: my_user.groups.add(foo_group) Above fails if two requests try to execute this code at once. Here is the database table and the failing constraint: myapp_egs_d=> \d auth