Django:获取today和SplitDateTime小部件的条目?

2024-05-16 06:32:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我用了:SplitDateTimeWidget来分割DateTime字段

appointment = forms.DateTimeField(widget=forms.SplitDateTimeWidget)

在模板端,我使用jQuery为每个字段使用datePicker和TimePicker。在

当我尝试按以下代码筛选与今天日期相关的条目时:

^{pr2}$

它显示了昨天8月17日的参赛作品:(真是太奇怪了!在

我试着在模型中分割日期和时间,结果也是一样的!在

你知道怎么解决这个问题吗?!在


Tags: 代码模板datetimedatepicker条目formswidgetjquery
1条回答
网友
1楼 · 发布于 2024-05-16 06:32:00

settings.py TIME_ZONE中修复时区设置

默认值:'America/Chicago'

来自the docs的一些有用信息摘录:

A string representing the time zone for this installation. See available choices.

(...)

Note that this is the time zone to which Django will convert all dates/times not necessarily the timezone of the server.

(...)

Django cannot reliably use alternate time zones in a Windows environment. If you're running Django on Windows, this variable must be set to match the system timezone.

相关问题 更多 >