title: Django, use of ForeignKey's value within model
body: <p>I would like to make a system, which is photos belong to projects. I also enabled that I can upload a zipfile directly for a project and it will unzip and register the photos to the specified project. However, I am having troubles while defining the <code>Photo</code> class.  </p>
  
  <p>I need to get the value of <code>Project.file_zip.path</code> with the current instance for defining <code>img</code> field's <code>upload_to</code> attribute. However, when I tried like below, it returns with <code>AttributeError: 'ForeignKey' object has no attribute 'file_path'</code>. How do I fix that?</p>
  
  <pre><code>class Project(models.Model):
  ....
  owner=models.ForeignKey(User)
  file_zip=models.FileField(upload_to='projects/%Y/%m/%d')
  
  def __unicode__(self):
      return self.project_name
  
  def file_path(self):
      return re.search(re.search('[^\s]+(?=\.zip)', self.file_zip).group(0))
  
  class Photo(models.Model):
      belongs_to=models.ForeignKey(Project)
      img=models.ImageField(upload_to='/home/contact/python_project/all_bugs_will_reveal/'+belongs_to.file_path())
      desc=models.CharField(max_length=255)
  </code></pre>