Python Django被推到了错误的日期

Python Django被推到了错误的日期,python,django,Python,Django,请帮忙!!! 我在视图中使用localzone的值date,但在数据库中,Django使用UTC的值date。。。 我必须做什么,按我当地的时区输入基准日期?(我的本地区欧洲/基辅) 请提供帮助)严格来说,这并不是对您问题的回答,但一般来说,最佳做法是以UTC存储时间,并在显示时间将其转换为您想要的任何时区。这样就减少了时间的模糊性。严格来说,这不是对您问题的回答,但一般来说,最佳做法是以UTC存储时间,并在显示时间将其转换为您想要的任何时区。这样就减少了时间的模糊性。设置中有两个变量。py #

请帮忙!!! 我在视图中使用localzone的值date,但在数据库中,Django使用UTC的值date。。。 我必须做什么,按我当地的时区输入基准日期?(我的本地区欧洲/基辅)


请提供帮助)

严格来说,这并不是对您问题的回答,但一般来说,最佳做法是以UTC存储时间,并在显示时间将其转换为您想要的任何时区。这样就减少了时间的模糊性。

严格来说,这不是对您问题的回答,但一般来说,最佳做法是以UTC存储时间,并在显示时间将其转换为您想要的任何时区。这样就减少了时间的模糊性。

设置中有两个变量。py

# Local time zone for this installation. Choices can be found here:             
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name                         
# although not all choices may be available on all operating systems.           
# On Unix systems, a value of None will cause Django to use the same            
# timezone as the operating system.                                             
# If running in a Windows environment this must be set to the same as your      
# system time zone.                                                             
TIME_ZONE = 'UTC'

# If you set this to False, Django will not use timezone-aware datetimes.       
USE_TZ = True

通过设置这两个变量,您可以控制django存储和打印日期的方式。

设置中有两个变量。py

# Local time zone for this installation. Choices can be found here:             
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name                         
# although not all choices may be available on all operating systems.           
# On Unix systems, a value of None will cause Django to use the same            
# timezone as the operating system.                                             
# If running in a Windows environment this must be set to the same as your      
# system time zone.                                                             
TIME_ZONE = 'UTC'

# If you set this to False, Django will not use timezone-aware datetimes.       
USE_TZ = True
通过设置这两个变量,您可以控制django存储和打印日期的方式