Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a really strange Http500 error when loading dynamically generated images. And for some reason it only happens sometimes. The apache error log doesn't show any errors. The django development server used to serve them fine in development.

Example from the logs:

174.255.117.79 - - [04/Feb/2013:12:00:46 -0600] "GET /images/gender/ HTTP/1.1" 500 531 "http://okstereotype.me/results/" "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; XT862 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
174.255.117.79 - - [04/Feb/2013:12:00:46 -0600] "GET /images/bodytype/ HTTP/1.1" 500 531 "http://okstereotype.me/results/" "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; XT862 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
174.255.117.79 - - [04/Feb/2013:12:00:46 -0600] "GET /images/religion/ HTTP/1.1" 200 30722 "http://okstereotype.me/results/" "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; XT862 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
174.255.117.79 - - [04/Feb/2013:12:00:46 -0600] "GET /images/smoking/ HTTP/1.1" 200 58577 "http://okstereotype.me/results/" "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; XT862 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
174.255.117.79 - - [04/Feb/2013:12:00:47 -0600] "GET /images/ethnicities/ HTTP/1.1" 500 531 "http://okstereotype.me/results/" "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; XT862 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"
~

And sometimes they load:

192.168.1.4 - - [04/Feb/2013:12:11:20 -0600] "GET /images/gender/ HTTP/1.1" 500 531 "http://okstereotype.me/results/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.1.4 - - [04/Feb/2013:12:11:20 -0600] "GET /images/religion/ HTTP/1.1" 200 41967 "http://okstereotype.me/results/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.1.4 - - [04/Feb/2013:12:11:20 -0600] "GET /images/ethnicities/ HTTP/1.1" 200 44148 "http://okstereotype.me/results/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.1.4 - - [04/Feb/2013:12:11:20 -0600] "GET /images/bodytype/ HTTP/1.1" 200 44471 "http://okstereotype.me/results/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0"
192.168.1.4 - - [04/Feb/2013:12:11:20 -0600] "GET /images/smoking/ HTTP/1.1" 200 59910 "http://okstereotype.me/results/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0"

The images are generated with a view:

(r'^images/(\w+)/$', mysite.views.show_pic)

And the view uses the PIL library to draw and save the image like so:

response = HttpResponse(mimetype="image/png")
img.save(response, "PNG")

All my static css is served correctly though. Any ideas?

share|improve this question
    
Django should send you an email when an internal error occurs -- these contain a traceback which identifies the problem. –  mgorven Feb 4 '13 at 18:32
    
I used the logging hack from this question because I'm too lazy to set up mail. Basically it was a problem with object persistence when a user clicks back and then forward instead of going through forms one by one. Thanks a lot mgorven. –  lqdc Feb 4 '13 at 19:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.