【发布时间】:2020-07-09 19:21:06
【问题描述】:
当我在 Heroku 调度程序中看到它时,我的应用程序将 timezone.now() 显示为 UTC 时间。我还构建了一个自定义的 manage.py 命令来测试它,但它仍然显示 UTC 时间。
这是我的 settings.py
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
这是我的个性化 manage.py 命令 managemet/commaands/abhiwaqt.py
from django.core.management.base import BaseCommand, CommandError
from django.apps import apps
from Directory.utils import *
class Command(BaseCommand):
help="Refresh models and its fields."
def handle(self,*args, **options):
try:
print(timezone.now())
except:
raise CommandError("Something went wrong")
设置 TIME_ZONE='Asia/Kolkata' 我遇到了这个问题。
【问题讨论】: