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

Posted May 20, 2020 1.1k views

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)

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.

Submit an Answer
1 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')