Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6138757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:54:21+00:00 2026-05-23T17:54:21+00:00

@transection.commit_on_success def recordIt(…) try: …. recordable = firstDataInsertionFunction(…) if recordable: myRec = SecondDataInsertion(…..) except:

  • 0
@transection.commit_on_success
def recordIt(...)
   try:
       ....
       recordable = firstDataInsertionFunction(...)
       if recordable:
          myRec = SecondDataInsertion(.....)

    except:
       ....

As for commit_on_success, if my second data insertion fails, django must automatically rollback, so my first data insertion will be rolled back too…

But this is not working, and first inserted data is saved to db, while i could not see the result of second insertion on my database… Is try/except causes commit_on_success to fail? Because as documentation says:

If the function returns successfully, then Django will commit all work done within the function at that point. If the function raises an exception, though, Django will roll back the transaction.

And try handles all exceptions. Is is the problem of my not working commit_on_success?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:54:21+00:00Added an answer on May 23, 2026 at 5:54 pm

    First of all, don’t ever do except:. It’s just bad, and catches too much, and hides bugs.

    And yes, if you handle the exception, then commit_on_success cannot possibly know there was an error. If you need to run logic on exception, reraise it afterwards (just raise, with no argument). Or rollback yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to hibernate. I have a transaction that fails with a HibernateException, yet
I'm trying to use Django transactions on MySQL with the commit_on_success decorator . According
I have a WCF service that uses ODP.NET to read data from an Oracle
SharePoint does not provide transaction (rollback and commit) support on List data operations. What
Setup: Python script A inserts data to a database every 15 minutes Python script
Say a stored procedure on MSSQL Server uses an SQL transaction using BEGIN TRANSACTION/COMMIT
Does the inserts are finished with the transaction commit? Or they can be finished
I have two PL/SQL Stored procedure each handling its own Transaction (Begin/Commit and Rollback
Is it possible to use the SQL BEGIN TRANSACTION, COMMIT TRANSACTION, ROLLBACK TRANSACTION when
I need to do transactions (begin, commit or rollback), locks (select for update). How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.