title: Getting file extension in Django template
body: <p>I have model like this:</p>
  
  <pre><code>class File(models.Model):
      name = models.CharField(max_length=45)
      description = models.CharField(max_length=100, blank=True)
      file = models.FileField(upload_to='files')
  </code></pre>
  
  <p>I get all File objects in my view and according to the type of file, I would like to print appropriate a class:</p>
  
  <pre><code>&lt;a class="pdf"&gt;link&lt;/a&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;a class="word"&gt;link&lt;/a&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;a class="other"&gt;link&lt;a/&gt;
  </code></pre>
  
  <p>in my template.</p>
  
  <p>How can I get file extension in Django template?</p>
  
  <p>I would like to do somethink like this:</p>
  
  <pre><code>{% for file in files %}
      {% if file.get_extension == 'pdf' %}
             &lt;a class="pdf"&gt;link&lt;/a&gt;
      {% elif file.get_extension = '.doc' %}
             &lt;a class="word"&gt;link&lt;/a&gt;
      {% else %}
             &lt;a class="other"&gt;link&lt;a/&gt;
      {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>Of course, 'file.get_extension' doesn't exist...</p>