Could you please help me to get image upload working on a view with django forms?
class User_Profile(models.Model):
    user = models.OneToOneField(User, unique=True, related_name='profile')
    photo  = models.ImageField(upload_to = 'profiles/', null=True, blank=True)
class ProfileForm(forms.ModelForm):
        class Meta:
            model = User_Profile
            exclude = ('user')
    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)
My html form already contains enctype="multipart/form-data"
Uploading is the process of moving digital files such as photographs or documents from your computer and placing them on to a central server so that someone else can retrieve them or to a website so others can see them.
You don't seem to be binding the file data to the form.
profile_form = ProfileForm(request.POST, request.FILES, instance=request.user.profile) 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With