title: django: commit and raise inside transaction.atomic()
body: <p>We are trying to migrate from <code>commit_manually</code> to <code>atomic</code> so we can upgrade Django to at least 1.8 in a legacy project. In most of cases we need to do something like that:</p>
  
  <pre><code>with transaction.atomic():
      obj = Entity.objects.select_for_update().get(pk=pk)
      try:
          obj.do_something()
          obj.set_some_status()
          obj.save()
      except SomeException:
          obj.set_failed_flag()
          obj.save()
          raise
  </code></pre>
  
  <p>becuase the callee needs this exception information to continue with the certain flow. But in this case the transaction/savepoint will be rolled back and that's not what we want since we want <code>obj.set_failed_flag()</code> to be committed. Also it seems logical to set it inside the same atomic block since we already have a locked row for this object. </p>
  
  <p>Any ideas/patterns? Thanks in advance!</p>
  
  <p>P.S. It was so easy with old manual transaction management!</p>
  
  <p>P.P.S. We use exceptions also for "early-exit" and moving to some flags etc. would bring a log of mess and I personally would love to avoid it.</p>