I have an Admin change page for a model that has two ImageFields. It’s been working fine for months – new objects have been created with images of various sizes uploaded.
But recently we’ve found that if one/both images is slightly large – even, say, 150KB – then submitting the form means the page just sits there, the browser’s progress bar not really moving, for several minutes until I give up.
When I’ve tried images that are more like 30KB each, the page refreshes almost instantly, with the images saved.
I’m stumped. I’m having trouble getting any useful logging output to appear, which doesn’t help. The site is hosted on cPanel served by Passenger. There’s plenty of disk space and the site is under almost no load. The same issue happens for the other main user too, so it’s not my connection.
Any suggestions for what else to investigate?
Hmmm… 150K is tiny for an image.
My initial guess would be that something in the stack is limiting the total size of the POST request. (Perhaps 64K?) I’d check everything in the stack that exists logically in front of Django for some type of upload limit.
This is well below the 2.5MB that Django uses by default for in-memory storage of an uploaded file, so I don’t think there’s anything needing to be checked from the cacheing side.
Thanks Ken (I was just writing the below when you replied). Yes, it is tiny for an image isn’t it, which is why this seems so peculiar. I may need to ask the hosting company if there’s something I don’t know about preventing this.
Using Firefox and looking at the developer tools, her’s the Request Timings, after leaving it doing nothing for around 30 seconds.
The request in the network tab lists this one POST request and has a column for “Transferred”, in which it has NS_BINDING_ABORTED.
The Request tab looks like it’s OK – a lot of form data including the images – and the Response tab says “No response data available for this request”.
The Headers shows that “548.57 kB” was transferred – mostly the two images I was uploading.
Yea, if you don’t have access to either the web server logs (normal and error) or the container logs, it’s going to be tough to identify where along the line this is getting dropped - especially if it’s not getting far enough into your code for your logging to kick in.
(It might be worthwhile to up your logging level and include a log for django.request
just to see if anything is coming through. (Possibly django.security
as well.)
Checking your hosting provider’s site docs or contacting them directly is likely to be your best bet.
Thanks Ken. Testing various slightly-differently sized images, it does seem to start failing somewhere around the 64KB mark – a good guess!