title: Django: generate download link
body: <p>I have a <code>File</code> model, which store <code>path</code> field - path in the filesystem to file. All files are stored in MEDIA_ROOT/files</p>
  
  <p>In template I want generate download link for <code>File</code> object. What is the best way to do this? Should I use static file handling in django?</p>
  
  <p>TIA!</p>
  
  <p><strong>UPD</strong></p>
  
  <p><code>File</code> model</p>
  
  <pre><code>class File(models.Model):
      item = models.ForeignKey(Item)
      file = models.FileField(upload_to = os.path.join(MEDIA_ROOT,'items'))
      format = models.CharField(max_length = 255)
  </code></pre>
  
  <p>In item's View I do the following:</p>
  
  <p><code>files = File.objects.filter(item_id = id)</code></p>
  
  <p>and the pass <code>files</code> to the template</p>
  
  <p>in template I use <code>files.1.file.url</code> for example and still have bad url like <code>site.com/home/dizpers/...</code></p>
  
  <p><strong>UPD2</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/1756190/django-filefield-url-not-relative">Related question</a></p>
  
  <p><strong>Solution</strong></p>
  
  <p>My problem was in File model, in <code>file</code> field. In upload_to parameter I use absolute path, but must use relative path:</p>
  
  <p><code>file = models.FileField(upload_to = 'items')</code></p>