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.
<Error>
<Code>NoSuchKey</Code>
<BucketName>financal-space</BucketName>
<RequestId>tx000000000000004683770-005ec5341d-ab90b1-ams3b</RequestId>
<HostId>ab90b1-ams3b-ams3-zg02</HostId>
</Error>
Here is my image post request
if 'imagechange' in request.POST and request.FILES['image']:
user = request.user.id
image = request.FILES['image']
fs = FileSystemStorage()
image_fs = fs.save(image.name, image)
image_new = CustomUser.objects.filter(user=user).update(image=image_fs)
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!
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 = form.save(commit=False)
edit.save()
return redirect('settings')
else:
return redirect('dashboard')
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.