开源软件名称(OpenSource Name):jamesmfriedman/django-easytz开源软件地址(OpenSource Url):https://github.com/jamesmfriedman/django-easytz开源编程语言(OpenSource Language):Python 100.0%开源软件介绍(OpenSource Introduction):Django EasyTZTimezone localization without any thinking or doing whatsoever. The purpose of this django app is to piggy back off of Django's already great timezone handling and add some automagic to the equation. This package is perfect for you if:
Setup
How It WorksOn the client side, jstz (http://pellepim.bitbucket.org/jstz/) is used to set a cookie with the users timezone. A middleware picks up the cookie and activates the timezone using Django's timezone handling. If a user is authenticated, it will also set the timezone in the session under a key called timezone as well as save it to the database. Anytime you want to access a users timezone, you can do so by calling from django.utils import timezone
def foo(request):
timezone.localtime(timezone.now(), request.user.tz)
... ModelThere is a simple storage model in
If you want to cut down on redundant queries, just make sure to select_related timezone if you are accessing the user = User.objects.select_related('timezone').get(user_id = 1)
users = User.objects.select_related('timezone').all() |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论