title: Django: display time it took to load a page on every page
body: <p>In Django, how can I return the time <strong>it took to load a page</strong> (not the date) in <strong>every</strong> page of the site, <strong>without</strong> having to <strong>write in every views.py</strong> a code similar to the following one?</p>
  
  <pre><code>start = time.time()
  #model operations
  loadingpagetime = time.time() - start
  </code></pre>
  
  <p>If using a <code>TEMPLATE_CONTEXT_PROCESSOR</code> is the best option.<br>
  How would I get the whole page loading time from there, instead of just getting the template loading time?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>As the initial question doesn't seem to be clear enough, here is an approach of what would be the <strong>Python version</strong> of what I want to do.</p>
  
  <pre><code>#!/usr/bin/env python
  import cgitb; cgitb.enable() 
  import time
  print 'Content-type: text/html\n\n'
  
  start = time.time()
  
  print '&lt;html&gt;'
  print '&lt;head&gt;'
  print '&lt;/head&gt;'
  print '&lt;body&gt;'
  print '&lt;div&gt;HEADER&lt;/div&gt;'
  print '&lt;div&gt;'
  print '&lt;p&gt;Welcome to my Django Webpage!&lt;/p&gt;'
  print '&lt;p&gt;Welcome to my Django Webpage!&lt;/p&gt;'
  print '&lt;p&gt;Welcome to my Django Webpage!&lt;/p&gt;'
  print '&lt;/div&gt;'
  
  time.sleep(3)
  loadingtime = time.time() - start
  
  print '&lt;div&gt;It took ',loadingtime,' seconds to load the page&lt;/div&gt;'
  print '&lt;/body&gt;'
  print '&lt;/html&gt;'
  </code></pre>