title: Django Transactions: How to run extra code during rollback?
body: <p>Imagine you have a <code>User</code> model in your web app, and that you need to keep this user in sync with an external service via an API. Thus, when you create a user locally, you need to create it remotely as well.</p>
  
  <p>You have all your operations under <code>transaction.atomic()</code> and you try to keep all your 3rd-party API calls <strong>after</strong> the atomic block, which is reasonable.</p>
  
  <p>But, a system being a system, it grows in complexity until the point you have some really hard to remove 3rd-party calls within an update call.</p>
  
  <p>That said, is there a way to extend Django's transaction mechanism, kind of adding some callback functions, like <code>rollback.add_callback(clean_3rdparty_user(user_id=134))</code>?</p>
  
  <p>That way I can guarantee that all necessary rollback actions are taken and my system is in sync?</p>