title: Django- Check the filetype of an uploaded file and then alter the template
body: <p>I want to write a function that checks the extension of the uploaded file and depending on that assigns a variable a value.<br>
  I hope it makes sense. I basically want to check the filetype of an uploaded file and then alter the template accordingly.<br>
  The code that I am thinking of implementing is something like this but I am kind of confused </p>
  
  <h1>models.py</h1>
  
  <pre><code>class ScribbleMedia(models.Model):
           media = models.FileField(upload_to=get_file_path)
           typecheck=find_typecheck
           def __unicode__(self):
            return self.media
  </code></pre>
  
  <h1>but I don't know where to write this function</h1>
  
  <pre><code>def find_typecheck(instance, filename):
          label=filename
          ext = filename.split('.')[-1]
          if ext == 'jpeg':
              a=1
          else:
              a=2
          return a
  </code></pre>
  
  <h1>in html template I should be able to do this</h1>
  
  <pre><code>{% if ScribbleMedia.typecheck ==1 %}
      do something
  {% else %}
      do something else
  {% endif %}
  </code></pre>