Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch pytz to zoneinfo #44

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions {{cookiecutter.project_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ With [ruff](https://github.com/astral-sh/ruff), not automated yet as part of CI

```bash
ruff check . --fix
fuff format
```
ruff format
```
1 change: 0 additions & 1 deletion {{cookiecutter.project_name}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ psycopg = "^3.2.1"
drf-nested-routers = "^0.94.1"
drf-spectacular = "^0.27.2"
boto3 = ">=1.35.10"
pytz = "^2024.1"

{% if cookiecutter.heroku_app_name | length %}
whitenoise = ">=6.7.0" #for heroku serving static files for admin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from os import getenv

import pytz
from django.utils import timezone
import zoneinfo


class TimezoneMiddleware:
def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
environment_timezone = getenv('USER_TZ', 'Asia/Jerusalem')
activated_timezone = pytz.timezone(environment_timezone)
environment_timezone = getenv("USER_TZ", "Asia/Jerusalem")
activated_timezone = zoneinfo.ZoneInfo(environment_timezone)
timezone.activate(activated_timezone)
return self.get_response(request)