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

  • SEARCH
  • Home
  • 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 8871757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:04:21+00:00 2026-06-14T18:04:21+00:00

I have a post_save handler that inserts additional records into the database referring to

  • 0

I have a post_save handler that inserts additional records into the database referring to the instance that was just created or updated. However, an error (perhaps a constraint violation) may occur when inserting the additional records.

If an exception occurs in the post_save handler, is it still possible that the initial instance will be committed?

The answer might depend on these sub-questions:

  • Does Django’s auto-commit mode commit before or after the post_save signal?
  • Does Django attempt to use nested transactions to rollback the instance being saved if an error occurs in post_save?
  • 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-06-14T18:04:22+00:00Added an answer on June 14, 2026 at 6:04 pm

    According to the docs, if you are using autocommit changes to the initial instance will be committed on .save() before any post_save signal handler. An exception in post_save will not rollback the changes to the initial instance.

    You can confirm this by looking at the source to save_base in django/db/models/base.py. The autocommit would occur on line 555 (in 1.4.2), but the post_save signal isn’t sent until line 564. You can also see that Django does not attempt to use any nested transactions in .save().

    If you are using django.middleware.transaction.TransactionMiddleware and have not overridden its behavior with an autocommit decorator, an exception during post_save would rollback the entire transaction, including the changes to the initial instance.

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

Sidebar

Related Questions

I have a simple Django-Piston Handler that creates a new instance of a model
I have form object that I set to request in GET request handler in
I have a handler that handles single files (text based) perfectly. I can receive
I have a database which has raw text that needs to be analysed. For
I have a django instance hosted via apache/mod_wsgi. I use pre_save and post_save signals
I have a post-build event that runs some commands for a c# project. The
I have a post-commit hook in svn that runs fine from the command line
I have a job (scheduled by delayed_job ) that sends an email when a
I have a webservice in django that I need to serve requests as fast
I have a problem with django's MVC. I understand that this is not the

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.