wsgi and python print statements
Solution 1:
Use WSGIRestrictStdout option:
WSGIRestrictStdout Off
or replace sys.stdout with sys.stderr in Django WSGI star script:
import sys
sys.stdout = sys.stderr
Writing To Standard Output
No WSGI application component which claims to be portable should write to standard output. That is, an application should not use the Python print statement without directing output to some alternate stream. An application should also not write directly to sys.stdout.
Solution 2:
In general, it is better to use logging for any kind of debug output in a web app and never use print statements at all. Or use them in the form:
print >> environ['wsgi.errors'], "message to be printed"
It is best to get rid of sys.stdout by making it a copy of sys.stderr just in case.
If you do development on a UNIX server, you can have two terminal windows open, one to run Django and the second one to do
tail -f loggingfile
And you get pretty much the same effect as using print statements, but you can use the standard logging
module to generate the output, and in the production app, you just change the filter setting to not show DEBUG level messages.