In my app I allow users to have a profile picture. And I would like them to be able to change it. Surprisingly, I didn't find anything on how to accomplish that.
Here is what I tried:
models.py
        class UserProfile(FacebookProfileModel):
           user = models.OneToOneField(User)
           profilepic = models.ImageField(upload_to="profilepics/", default="blabla.jpg")
my html:
       <form method='post' action='{%url myproject.views.changes %}>
       <div class="controls">
       <input type="file" name="image">
       </div>
       <input type="submit">
       </form>
my view:
      def changes(request):
          if 'image' in request.POST:
             image = request.POST.get('image')
             userprofile.profilepic.url = image
             userprofile.save()
When I do that, I get the following error message:
       'AttributeError at /my/site/
        can't set attribute'
Any idea on how I could accomplish that? Thank you
 
     
     
    