Django IPython sqlite抱怨天真的datetime [英] Django IPython sqlite complains about naive datetime

查看:147
本文介绍了Django IPython sqlite抱怨天真的datetime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Django 1.4中有一个新项目,使用sqlite db。还要使用django_extenstions'shell_plus,没有问题。



当我安装IPython时, shell shell_plus 开始抱怨:

  / path / to / my / virtualenv / lib / python2 .7 / site-packages / django / db / backends / sqlite3 / base.py:50:
RuntimeWarning:SQLite收到一个天真的datetime(2012-07-29 13:15:45.229464),而时区支持是活动的。

似乎IPython本身使用不知道的datetimes。如何修复?



编辑:



我不想禁用Django的时区支持。

解决方案

我把它放在我的local_settings.py中:

 使用ipython时,注意以下错误:
#/ django / db / backends / sqlite3 / base.py:50:RuntimeWarning:
# SQLite收到了一个天真的日期时间(2012-11-02 11:20:15.156506),而时区支持是活跃的。

import warnings
import exceptions
warnings.filterwarnings(ignore,category = exceptions.RuntimeWarning,module ='django.db.backends.sqlite3.base',lineno = 53)


I have a new project in Django 1.4, using sqlite db. Also using django_extenstions' shell_plus with no problems.

When I installed IPython, both shell and shell_plus started to complain about:

/path/to/my/virtualenv/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py:50:
RuntimeWarning: SQLite received a naive datetime (2012-07-29 13:15:45.229464) while time zone support is active.

It seems IPython itself uses unaware datetimes. How can this be fixed?

EDIT:

I don't want to disable Django's timezone support.

解决方案

I put this in my local_settings.py:

#ignore the following error when using ipython:
#/django/db/backends/sqlite3/base.py:50: RuntimeWarning:
#SQLite received a naive datetime (2012-11-02 11:20:15.156506) while time zone support is active.

import warnings
import exceptions
warnings.filterwarnings("ignore", category=exceptions.RuntimeWarning, module='django.db.backends.sqlite3.base', lineno=53)

这篇关于Django IPython sqlite抱怨天真的datetime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆