title: What is the simplest way to retry a Django view upon an exception being raised?
body: <p>I want to rerun a Django view function if a certain exception is raised (in my case a serialization error in the underlying database). I want it to run with exactly the same parameters, including the same <code>request</code> object - as if the client had re-requested the URL.</p>
  
  <p>There are many database queries in the view, and the exception could be raised on any one of them - and it won't work to rerun just one of the queries in isolation, so I think I need to wrap the entire view function in a try/except block and loop until success.</p>
  
  <p>But I have several view functions which might raise such exceptions, so I want a generic solution. I also want to be able to retry up to a certain number of times and then fail.</p>
  
  <p>Is there any simple solution?</p>