title: How to get the link of the file in a FileField?
body: <p>how can I get the link of a <code>FileField</code>? I tried the <code>url</code> field, but it gives the file path:</p>
  
  <pre><code>In [7]: myobject.myfilefield.path
  Out[7]: u'/home/xxxx/media/files/reference/1342188147.zip'
  
  In [8]: myobject.myfilefield.url
  Out[8]: u'/home/xxxx/media/files/reference/1342188147.zip'
  </code></pre>
  
  <p>I was expecting to get <code>http://&lt;mydomain&gt;/media/files/reference/1342188147.zip</code></p>
  
  <p>How can I get that? Do I have to build the string manually?</p>
  
  <p>EDIT</p>
  
  <p>My MEDIA_URL was not set, but I still can't get it to work:</p>
  
  <p><b>settings.py</b></p>
  
  <pre><code>MEDIA_ROOT = '/home/xxx/media/'
  MEDIA_URL = 'http://xxx.com/media/'
  </code></pre>
  
  <p><b>models.py</b></p>
  
  <pre><code>class Archive(models.Model):
  
      #...
      file = models.FileField(upload_to="files")
  </code></pre>
  
  <p><b>in shell</b></p>
  
  <pre><code>a = Archive()
  a.file = "/some/path/to/file.txt"
  a.save()
  </code></pre>
  
  <p>Then I get for <code>a.path</code>:</p>
  
  <pre><code>"/some/path/to/file.txt"
  </code></pre>
  
  <p>and for <code>a.url</code>:</p>
  
  <pre><code>"http://xxx.com/media/some/path/to/file.txt"
  </code></pre>
  
  <p>When done programmatically, <code>a.file = "/some/path/to/file.txt"</code>, the file is not uploaded to <code>MEDIA_ROOT</code>. How can I upload a file in the directory defined by <code>upload_to</code>, i.e. in my case <code>/home/xxx/media/file.txt</code>?</p>