title: Uploading image files
body: <p>Could you please help me to get image upload working on a view with django forms?</p>
  
  <h2>Models.py</h2>
  
  <pre><code>class User_Profile(models.Model):
      user = models.OneToOneField(User, unique=True, related_name='profile')
      photo  = models.ImageField(upload_to = 'profiles/', null=True, blank=True)
  </code></pre>
  
  <h2>Forms.py</h2>
  
  <pre><code>class ProfileForm(forms.ModelForm):
          class Meta:
              model = User_Profile
              exclude = ('user')
  </code></pre>
  
  <h2>Views.py</h2>
  
  <pre><code>    if request.method == 'POST':
          profile_form = ProfileForm(request.POST, instance=request.user.profile)
  
          if profile_form.is_valid():
              profile_form.save()
              return HttpResponseRedirect('/panel/correct/')
  
      else:
          profile_form = ProfileForm(instance=request.user.profile)
  </code></pre>
  
  <p>My html form already contains <code>enctype="multipart/form-data"</code></p>