Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

Commit

Permalink
Suppress sqlite warnings for IPython on initialization
Browse files Browse the repository at this point in the history
It is more of an ugly hack, required because of django injecting
global callback in a database api.

Ideally, instead of registering adapter for `datetime.datetime`
(django.db.backends.sqlite3.base.py Line 76), django should do it
for a pseudo wrapper over `datetime.datetime` and use it everywhere,
so that other applications and libraries don't have to worry about
the behaviour being infected.

Signed-off-by: Rohan Jain <crodjer@gmail.com>
  • Loading branch information
crodjer committed Feb 9, 2013
1 parent 0e18fb0 commit 8b24546
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions django/core/management/commands/shell.py
Expand Up @@ -21,9 +21,20 @@ class Command(NoArgsCommand):

def ipython(self):
try:
import warnings
import exceptions

from IPython.frontend.terminal.ipapp import TerminalIPythonApp

sqlite_warnings = lambda action: warnings.filterwarnings(
action, category=exceptions.RuntimeWarning,
module='django.db.backends.sqlite3'
)

app = TerminalIPythonApp.instance()
sqlite_warnings("ignore")
app.initialize(argv=[])
sqlite_warnings("default")
app.start()
except ImportError:
# IPython < 0.11
Expand Down

0 comments on commit 8b24546

Please sign in to comment.