FileField does not work properly in template but in admin it works , Django , Digitalocean , Aws S3

I have some problems with the image field, I store them on AWS through DigitalOcean.

Fun Fact: When I upload an image on to the admin panel, it works fine, and when I’m trying to do the same in a template , image updates but does not get stored on AWS. When I try to click this image in the admin panel instead of an image I get this.

This XML file does not appear to have any style information associated with it. The document tree is shown below.


Here is my image post request

if 'imagechange' in request.POST and request.FILES['image']:
     user =
     image = request.FILES['image']
     fs = FileSystemStorage()
     image_fs =, image)
     image_new = CustomUser.objects.filter(user=user).update(image=image_fs)

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

So I find the solution : I changed a little bit my POST request to this

       if 'imagechange' in request.POST and request.FILES['image']:
              user = request.user
              profile = UserMembership.objects.get(user=user)
              form = UpdateUserImage(request.POST, request.FILES or None, instance=profile)
              if form.is_valid():
                    edit =

                    return redirect('settings')
                  return redirect('dashboard')

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel