Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#14550 closed (fixed)

commit_on_success no longer sets back to autocommit mode

Reported by: apollo13 Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


commit_on_success doesn't reset to the autocommit transaction state since r14288. If I understand the new decorator/context_manager code correctly we will need a leave_transaction_management in commit_on_success.exiting.

Change History (3)

comment:1 Changed 5 years ago by jbronn

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Here's how to reproduce. Create an application, and place the following in

from django.db import models

class Oblast(models.Model):
    Represents an Ukranian administrative region, or Oblast.
    ua_name = models.CharField(max_length=50)
    en_name = models.CharField(max_length=50)

    def __unicode__(self):
        return u'%s (%s)' % (self.ua_name, self.en_name)

Then, create a module in the application called, and insert the following:

from django.db import transaction
from models import Oblast

oblasts = [
    (u'Kiev', u'\u041a\u0438\u0457\u0432\u0441\u044c\u043a\u0430'),

def init_oblasts():
    for en_name, ua_name in oblasts:
        ob = Oblast(en_name=en_name)
def run():

    for en_name, ua_name in oblasts:
        ob = Oblast.objects.get(en_name=en_name)
        ob.ua_name = ua_name
    print transaction.is_dirty()

Assuming the code is inside an application entitled ukraine, and the database synced, then follow the below instructions:

  1. ./ shell
  1. from ukraine import load;
  1. Exit the shell
  1. ./ shell and query the database. The ua_name field is not set because the transaction was not committed. This does not happen in 1.2.X.

comment:2 Changed 5 years ago by Alex

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [14343].

comment:3 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top