Thanks Tom for your response. I am attaching piece of code of what I have 
done. I hope this could help. 

@transaction.atomic(None, True)
def reservation(request):
    
    if request.method == 'POST':
        reservation_form = ReservationForm(request.POST)
        if reservation_form.is_valid():
            for i in xrange(0, len(exclusive_assets)):

                    inventory = Inventory.objects.filter(asset_id = 
exclusive_assets[i])
                    asset_spec = 
AssetSpecification.objects.filter(asset_id_id=inventory,utilized_value=0).values_list('asset_id',
 
flat=True)
                    trans = transaction.savepoint()  //  Here I am trying 
not to commit the code and store it in transaction.

                    if asset_spec.count():
                        asset_port = AssetPorts.objects.filter(asset = 
asset_spec,usage='No')

                        for portNumber in asset_port:
                            AssetPorts.objects.filter(port_number = 
portNumber.port_number).update(usage='Yes')
                            trans = transaction.savepoint()  //  Here I am 
trying not to commit the code and store it in transaction.

                    else:
                        transaction.savepoint_rollback(trans) // If any 
time the condition is not met then there should be no update
                        

            transaction.savepoint_commit(trans) // Commit changes if all 
the conditions are met 
            return success(request)


and in settings file, I have done 
'default': {
        'ENGINE': 'django.db.backends.mysql', 
        'NAME': 'lab_on_demand_db',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
        'AUTOCOMMIT': 'False',
        }

I am using InnoDB engine with mysql.


Thanks, 
Simran

On Monday, May 11, 2015 at 4:27:50 PM UTC+5:30, Simran Singh wrote:
>
> I am really new to Django and I am using Django 1.8. Many of the 
> manual_transaction features have been depreciated in this. I have used 
> *@transaction.atomic(None, 
> True)* to pack the transaction and rollback the updates if at any point 
> the condition is not met. 
> I tried to store the transaction in savepoint and used  
> *savepoint_rollback* or *savepoint_commit* as per the condition. But I am 
> having no luck here. No matter where the control goes but as soon as atomic 
> block ends, it is committing the changes in mysql db.  
> Any kind of help or leads would be highly appreciated.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb214bbf-3e88-40a5-9b72-50e78b6e985d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to