Runtime Warning in django

╄→尐↘猪︶ㄣ 提交于 2019-12-03 20:51:48

You have to make the following changes:

In settings.py, you need to add following line:

USE_TZ = True

Also, in your code you should create aware datetime objects:

eg:

Instead of

import datetime

now = datetime.datetime.now()

You should do:

from django.utils.timezone import now

now_time = now()

This will make use of USE_TZ from settings.py and will create aware datetime objects instead of native.

You should read https://docs.djangoproject.com/en/dev/topics/i18n/timezones/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!