Get local timezone in django

后端 未结 9 642
轻奢々
轻奢々 2020-12-04 17:47

I have a mysql DATETIME value that is stored in system time, UTC. I need to convert that to my local timezone in django. Here is what I currently have:

9条回答
  •  佛祖请我去吃肉
    2020-12-04 18:46

    1: Define the timezone in your view

    from django.utils import timezone
    
    variable = timezone.now()
    

    2: Then use it in your template

    {% load l10n %}
    
    Teresina, {{variable |localize}}.
    

提交回复
热议问题