On Tue, Aug 18, 2009 at 16:19, Lokesh <[email protected]> wrote:

>
> Hi,
>
> Unable to perform rollback the transactions. Ended up with the
> following error
> "Transaction managed block ended with pending COMMIT/ROLLBACK"
>
> Can I rollback the db changes even if the code doesn't raise any
> excceptions?
>
> Here is the code:
> from django.db import transaction
> @transaction.commit_manually
> def view(request):
>    if request.method== "POST" :
>        print "in post"
>        new_user = User.objects.create_user(username="testing",
> email="[email protected]", password="lokesh")
>        print "return value new user = %s" % new_user
>        transaction.rollback()
>        return render_to_response("templates/listuser.html",
>                                      context_instance=RequestContext
> (request))
>    else:
>        print "in else"
>        return render_to_response("templates/listu.html",
>                                  context_instance=RequestContext
> (request))


You probably get this message when you are in the else block. There your
method ends without a commit() or rollback(), so django complains :D

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to