title: django exception handler middleware and handler500
body: <p>I have a django application with <code>handler500</code> set. I want to add custom exception handler to it.
  I create a middleware which handles process exception: </p>
  
  <blockquote>
    <p>Django calls process_exception() when a view raises an exception. process_exception() should return either None or an HttpResponse object. If it returns an HttpResponse object, the response will be returned to the browser. Otherwise, default exception handling kicks in.</p>
  </blockquote>
  
  <p><a href="https://docs.djangoproject.com/en/dev/topics/http/middleware/?from=olddocs#process-exception" rel="nofollow">https://docs.djangoproject.com/en/dev/topics/http/middleware/?from=olddocs#process-exception</a></p>
  
  <p>My <code>ErrorMiddleware</code> looks like:</p>
  
  <pre><code>class ErrorMiddleware(object):
      def process_exception(self, request, exception):
          try:
              #logic goes here
          except Exception:
              pass
          return None
  </code></pre>
  
  <p>My <code>settings</code> looks like:</p>
  
  <pre><code>MIDDLEWARE_CLASSES = (
      'my.error.ErrorMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
  )
  DEBUG = False
  </code></pre>
  
  <p>In this case, my browser never gets a response from page with exception. Though without my middleware in the list, I get <code>handler500</code> working correctly. </p>
  
  <p>I want default exception handling mechanism to be executed, without explicitly calling <code>handler500</code> view in my middleware.</p>
  
  <p><strong>UPD</strong>:</p>
  
  <p>handler500 module looks like this:</p>
  
  <pre><code>#imports ....
  
  def custom_500(request):
      """ Return an error ID (hash) that can be provided to support """
      return render(request, '500.html', {
          'timestamp': datetime.datetime.now().isoformat(),
          'diagcode': "hello",
          }
      )
  </code></pre>