Ticket #12579: 12579.diff
File 12579.diff, 970 bytes (added by , 12 years ago) |
---|
-
querysets.txt
1336 1336 created and the key already exists in the database, an 1337 1337 :exc:`~django.db.IntegrityError` will be raised. 1338 1338 1339 The ``get_or_create()`` method is not atomic.So if unique/unique together is not 1340 implemented on fields used in :meth:`get()` call at database level, 1341 concurrent calls to ``get_or_create()`` method end up creating duplicate objects in database. 1342 If a unique/unique together is implemented, multiple threads can get to the point of save() where 1343 one thread successfully creates the object while the others raise :exc:`~django.db.IntegrityError`. 1344 1339 1345 Finally, a word on using ``get_or_create()`` in Django views. As mentioned 1340 1346 earlier, ``get_or_create()`` is mostly useful in scripts that need to parse 1341 1347 data and create new records if existing ones aren't available. But if you need