python - 如何在 Django 中设置我自己的时区?

标签 python django timezone django-settings

我住在孟加拉国吉大港,我的时区是 GMT+6。如何在 Django 设置中更改到这个时区?

最佳答案

您可以将时区指定为 'Asia/Dhaka' TIME_ZONE setting [Django-doc] :

# settings.py

TIME_ZONE = 'Asia/Dhaka'
# …

请注意,如果 USE_TZ setting [Django-doc]设置为 True , 然后:

When USE_TZ is True, this is the default time zone that Django will use to display datetimes in templates and to interpret datetimes entered in forms.

关于python - 如何在 Django 中设置我自己的时区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61147405/

相关文章:

python - KeyError,与 ANSI 与 UTF-8 编解码器相关吗?

python - Django 模板可能出现 'if element in aList' 吗?

python - 在 Django Queryset 顶部返回完全匹配

django - 如何从本地主机(http)向django(https)发送POST请求?

java - 如果我在不同的国家/地区,我如何知道特定国家/地区的时间?

iphone - 在 iPhone 上获取时区信息以获取坐标

Python:如何在使用 str.lower 时避免字符串中的特定单词小写

python - 替换 FASTA 比对文件列中字母的所有实例

python - 如何从 FileField 获取 (txt) 文件内容?

在R中进行POSIXlt转换期间删除时区