Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
c9b22707
Kaydet (Commit)
c9b22707
authored
Eyl 04, 2017
tarafından
Jonatas CD
Kaydeden (comit)
Tim Graham
Eyl 04, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28479 -- Doc'd that transaction rollback doesn't revert model state.
üst
0891503f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
transactions.txt
docs/topics/db/transactions.txt
+23
-0
No files found.
docs/topics/db/transactions.txt
Dosyayı görüntüle @
c9b22707
...
...
@@ -176,6 +176,29 @@ Django provides a single API to control database transactions.
If you catch exceptions raised by raw SQL queries, Django's behavior
is unspecified and database-dependent.
.. admonition:: You may need to manually revert model state when rolling back a transaction.
The values of a model's fields won't be reverted when a transaction
rollback happens. This could lead to an inconsistent model state unless
you manually restore the original field values.
For example, given ``MyModel`` with an ``active`` field, this snippet
ensures that the ``if obj.active`` check at the end uses the correct
value if updating ``active`` to ``True`` fails in the transaction::
from django.db import DatabaseError, transaction
obj = MyModel(active=False)
obj.active = True
try:
with transaction.atomic():
obj.save()
except DatabaseError:
obj.active = False
if obj.active:
...
In order to guarantee atomicity, ``atomic`` disables some APIs. Attempting
to commit, roll back, or change the autocommit state of the database
connection within an ``atomic`` block will raise an exception.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment