title: Django: how to get the name of the template being rendered
body: <p>I'm implementing a <a href="http://getbootstrap.com">bootstrap</a> <code>navbar</code> as show in this example <a href="http://getbootstrap.com/components/#navbar">here</a></p>
  
  <p>Items in a navbar are <code>&lt;li&gt;'s</code> , the "selected" item has the attribute <code>class="active"</code>:</p>
  
  <pre><code>  &lt;li class="active"&gt; &lt;a href="#"&gt; Link1 &lt;/a&gt; &lt;/li&gt;
    &lt;li&gt;                &lt;a href="#"&gt; Link2 &lt;/a&gt; &lt;/li&gt;
  </code></pre>
  
  <p>In Django these items will be within a template, which gets included by any templates that are supposed to display the navbar. I'm thinking about doing it this way:</p>
  
  <pre><code>&lt;li&gt; &lt;a href="/"        class="{% if template_name == "home.djhtml"    %}active{% endif %}"&gt; Home    &lt;/a&gt; &lt;/li&gt;
  &lt;li&gt; &lt;a href="about/"   class="{% if template_name == "about.djhtml"   %}active{% endif %}"&gt; About   &lt;/a&gt; &lt;/li&gt;
  &lt;li&gt; &lt;a href="contact/" class="{% if template_name == "contact.djhtml" %}active{% endif %}"&gt; Contact &lt;/a&gt; &lt;/li&gt;
  </code></pre>
  
  <p>I would like to know if there is a built-in way to get the <code>template_name</code> (that is, the template being rendered, as passed to <code>render_to_response()</code>, in <code>views.py</code>)</p>
  
  <p>Sure, I could explicitly add a <code>template_name</code> variable to <code>render_to_response()</code>, which would solve the problem. But thinking about DRY I feel this shouldn't be needed.</p>