title: Catch exception on save in Django admin?
body: <p>I have a <code>pre_save</code> signal handler on a bunch of models, which write to a different database.  If something goes wrong, I'd like to abort the whole save, or failing that give a message to the user.</p>
  
  <p>Based on <a href="https://stackoverflow.com/questions/13964958/display-custom-message-from-signal-in-the-admin">Display custom message from signal in the admin</a>, I wrote a mixin with methods like:</p>
  
  <pre><code>class SafeSaveMixin(object):
      def save_model(self, request, *args, **kwargs):
          try:
              return super(SafeSaveMixin, self).save_model(request, *args, **kwargs)
          except Exception as e:
              self.message_user(request, e, messages.ERROR)
  </code></pre>
  
  <p>This allows me to throw an Exception from the <code>pre_save</code> handler and show the message to the user.  The problem is, even though this winds up skipping the actual <code>Model.save()</code>, the admin console doesn't see anything, so it still reports the object as successfully saved.</p>
  
  <p>If I changed the <code>pre_save</code> handler to a <code>post_save</code> handler, that would allow the base <code>Model.save()</code> to occur and at least Django would report the correct state of things, but the information I need in the other database is based on the <em>previous</em> state of the object, so I need to get to it before the save.</p>
  
  <p>I've also considered stuffing the error message into the object itself in the <code>pre_save</code> and pulling it out in the mixin's <code>save_model()</code> -- but this gets more complicated in the other <code>ModelAdmin</code> save methods like <code>save_formset()</code>.</p>
  
  <p>Is there any good way to do this?</p>