Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting django manage.py output (in windows) to a text file

I'm trying to redirect the output from manage.py to a text file, but only some output is getting redirected to the text file. How do I redirect all output to the text file?

My command prompt:

C:\Development\web-py\p1st2\pianos1st-system>python manage.py test > test_results.txt
.....................................................................................................................
----------------------------------------------------------------------
Ran 117 tests in 2.026s

OK

My test_results.txt file:

Creating test database for alias 'default'...
Destroying test database for alias 'default'...

I'm using Windows 7 32bit SP1 and Django SVN.

like image 618
Humphrey Avatar asked Mar 07 '11 02:03

Humphrey


1 Answers

Certain types of console messages will bypass the output redirection (or whatever using ">" is called). I noticed that sys.stderr.write() for instance did this.

Adding a "2>&1" at the end helps with this:

python manage.py test purchaseplans > test_results.txt 2>&1

Edit: Explanation of what is going on:
http://en.wikipedia.org/wiki/Redirection_(computing)#Redirecting_to_and_from_the_standard_file_handles

like image 143
Dolan Antenucci Avatar answered Oct 17 '22 23:10

Dolan Antenucci