title: Confused by middleware execution process, DJANGO
body: <p>Suppose I have the following class, as inspired by the Django documentation:</p>
  <blockquote>
  <pre><code>class SimpleMiddleware(object):
  
      def __ init__(self, get_response):
          self.get_response = get_response
  
      def __call__(self, request):
  
  
          response = self.get_response(request)
  
    
          return response
  
      def process_view(self, request, view_func, view_args, view_kwargs):
  
          return None
  </code></pre>
  </blockquote>
  <p>When reading Daniel Rubio's book 'Beginning Django', he explains that the order of execution is:</p>
  <ol>
  <li><code>__ init __</code> method triggered (on server startup)</li>
  <li><code>__ call __</code> method triggered (on every request)</li>
  <li>If declared, <code>process_view()</code> method triggered</li>
  <li>View method starts with <code>self.get_response(request)</code> statement in <code>__ call __</code></li>
  </ol>
  <p>What exactly does &quot;<code>__ call __</code> method triggered (on every request)&quot; mean? Does not 'triggering' the <code>__ call __</code> method actually trigger '<code>self.get_respone(request)</code>' automatically, thus calling either another middleware or a class?</p>
  <p>The Django documentation states that:</p>
  <blockquote>
  <p><code>process_view()</code> is called just before Django calls the view.`</p>
  </blockquote>
  <p>To me, this would have to mean that Django checks if the instance of the <code>'SimpleMiddleware'</code> class contains a method <code>'process_view()'</code> and then triggers that, before moving on to calling the <code>__ call __()</code> method, which 'calls the view'? Otherwise, if the <code>__ call __</code> method is triggered immediately, won't '<code>process_view()</code>' be missed since the <code>__ call __</code> method calls the view (or the next middleware)?</p>
  <p>Could someone please help me understand the execution process? How does Django go about this?</p>
  <p>Thank you</p>