0

The following Django HttpResponse doesn't show any text in the browser and I don't know why:

HttpResponse(u'Bad Request - Text does not show.', status=400, content_type='text/plain')

It works perfectly on my localhost, but the text message is not found anywhere when running the same code under NGINX in production.

Here's a production example URL: http://pixabay.com/get/abc.svg

Any ideas?

Simon Steinberger
  • 6,605
  • 5
  • 55
  • 97
  • Looking at the network details in the console, I see two requests to the svg. One is a 307 (internal redirect), the other is the 400 (to 78.47.54.106:443, for my instance) you mentioned. I'd suggest to look into the ALLOWED_HOSTS setting, as [this answer](http://stackoverflow.com/a/20618753/2672370) recommends. – Hunan Rostomyan Dec 05 '15 at 09:12
  • Nginx is probably cutting this for some of the status_codes - try changing 400 to something acceptable (200, 201, 204, 206, 301, 302, 303, 304, or 307) and see if this works. – abolotnov Dec 05 '15 at 09:27
  • Thanks for your ideas. I found the solution. It works when I remove the "u" in front of the string. Apparently, our NGINX has issues when it comes to unicode plain text bodies. – Simon Steinberger Dec 05 '15 at 09:54

0 Answers0