小编Lar*_*son的帖子

Django 1.9.2 AssertionError:数据库连接未设置为UTC

我现在已经使用PostgreSQL设置了3台服务器,到目前为止还没有看到这个问题.我现在正在设置第一台没有在丹麦服务器上运行的服务器,并且从Web访问数据库时我开始出错.

我可以毫无问题地使用createsuperuser,它创建了我的超级用户.但是,当我尝试使用它登录我的网站时,我得到了错误.

File "/usr/lib64/python3.4/site-packages/django/db/models/sql/compiler.py",    line 1239, in cursor_iter
sentinel):
File "/usr/lib64/python3.4/site-packages/django/db/models/sql/compiler.py", line 1238, in <lambda>
for rows in iter((lambda: cursor.fetchmany(GET_ITERATOR_CHUNK_SIZE)),
File "/usr/lib64/python3.4/site-packages/django/db/utils.py", line 102, in  inner
return func(*args, **kwargs)
File "/usr/lib64/python3.4/site-packages/django/db/backends/postgresql/utils.py", line 6, in utc_tzinfo_factory
raise AssertionError("database connection isn't set to UTC")
AssertionError: database connection isn't set to UTC
Run Code Online (Sandbox Code Playgroud)

我一直在看代码,错误来自这段代码.

from django.utils.timezone import utc
def utc_tzinfo_factory(offset):
    if offset != 0:
    raise AssertionError("database connection isn't set to UTC")
return utc
Run Code Online (Sandbox Code Playgroud)

虽然我无法找到偏移量的起始位置,但我无法弄清楚Django如何确定我的偏移量已关闭.

我的postgresql数据库的时区设置为UTC,并验证了django文档中写的所有postgresql参数,我现在已经没想到为什么会这样.

我希望有人可以帮忙吗?

python3.4 -V:Python 3.4.3

psql -V:psql(PostgreSQL)9.2.15

django-admin --version:1.9.2

更新11/8-2016 …

python django postgresql

6
推荐指数
4
解决办法
2212
查看次数

标签 统计

django ×1

postgresql ×1

python ×1