Suppress warning output on dumpdata manage.py?

I use the django dumpdata and loaddata commands to facilitate data export. However, I currently have some unsolved failure warnings, so when I write dumpdata output to a file, the warnings end at the top of the file and I have to manually clear the dump files every time. Is there a way to suppress or avoid warnings that dumpdata output is legal json without having to manually delete the warning text each time?

+6
source share
2 answers

you can also suppress warnings without having to embed code anywhere, by flags on the python interpreter

eg,

python -Wi manage.py dumpdata 

https://docs.python.org/2/using/cmdline.html#cmdoption-W

+11
source

You can try to override warning.showwarning . Put the following code somewhere that will be imported when you dumpdata (e.g. your settings.py ):

 import warnings warnings.showwarning = lambda *x: None 
+6
source

All Articles