Ouput timezone aware django datetime fields without filters

前端 未结 2 1491
無奈伤痛
無奈伤痛 2021-01-24 14:23

Hi i upgraded to django 1.4 and i want to take advantage of the timezone support, i got a few datetime fields saved in postgres, and they were saved assuming the timezone of my

2条回答
  •  别那么骄傲
    2021-01-24 15:02

    Unfortunately the only way I found to work with this is to convert the date to users time zone and provide a custom template tag to get the piece you want, something like:

    {% url event artist_slug=concert.slug_name hour=concert.datetime|localtime|hour_of_day %}
    

    Where hour_of_day is a custom tag returns the current hour in the correct localtime.

提交回复
热议问题