问题
I'm using Django's django-extensions to run an iPython notebook with access to the Django models (as detailed here http://andrewbrookins.com/python/using-ipython-notebook-with-django/). When I make model queries, the notebook shows the underlying SQL queries executed by Django, like so:
Can I hide this SQL? It's so voluminous it makes the display unusable at times.
回答1:
with recent version, you could use
%%capture variable
the code
to capture stdout and stderr into a variable adding the --no-stdout flag
%%capture --no-stdout variable
wont capture stdout, thus displaying it.
Also, please, IPython (upper casse I) preferably, ipython accepted, but try to avoid iPython
来源:https://stackoverflow.com/questions/14738163/hide-sql-statements-when-running-ipython-notebook-with-djangos-django-extension