title: Django last visited urls list
body: <p>I'm writing django-based forum, and i've decided it would be suitable for user to browse his last pages. Also, user tracking middleware can be a good aid for suggestions, and so on.</p>
  <ol>
  <li><p>I think, the easiest way to do it is to use the <code>Django Middleware</code>, but i ran into a problem: how to get the title of the page being rendered? Override <code>process_template_response</code>? Can i get the <code>{% block title %}</code> there?</p>
  </li>
  <li><p>The second server-side way is to use a template tag, i think. In the easiest case, it should should look like <code>{% block title %}{% last_visited _(&quot;Page title&quot;) %}{% endblock %}</code>.</p>
  </li>
  <li><p>The third, stupid way: make an ajax script, that will push current user's opened page with title  into his session. So, this method will just avoid us getting the page title.</p>
  </li>
  </ol>
  <p>I think, the right way is to get the <code>title</code> block from a template context in middleware. How can i do it?</p>
  <p>Thanks.</p>
  <h1>UPDATE</h1>
  <p>Made the <a href="https://gist.github.com/night-crawler/6193730" rel="nofollow noreferrer">gist</a> with realisation of the second method using <code>templates</code> and <code>django.cache</code>. The simplest usage:</p>
  <pre><code>{% block title %}{% save_visited _(&quot;Profile setup&quot;) %}{% endblock %}
  ...
  {% load_visited 'visited' %}
  {% for title, uri, dt in visited %}
      &lt;a href=&quot;{{ uri }}&quot;&gt;{{ title }} {% trans &quot;at&quot; %} {{ dt }}&lt;/a&gt;&lt;br/&gt;
  {% endfor %}
  </code></pre>
  <p>Also, i'm still looking for a method allows to get the page's <code>{% block title %}</code> in the middleware. Of course, i can use, i.e., <code>lxml</code> parser and get the <code>title</code> in the <code>process_response</code> method, but it is an ugly overkill.</p>
  <p>Thanks for any advice.</p>