emencia / django-blog-lotus

A weblog application with Django.
https://django-blog-lotus.readthedocs.io/
MIT License
5 stars 1 forks source link

Django 4.0.x support #34

Closed sveetch closed 1 year ago

sveetch commented 2 years ago

It's new, it's fresh, let's add its support.

sveetch commented 1 year ago

Django 4.0 brought zoneinfo support to replace pytz usage from django.utils.timezone interface: https://docs.djangoproject.com/en/4.0/releases/4.0/#zoneinfo-default-timezone-implementation

zoneinfo have something to help for transition to maintain compatibility with Django <4.0 : https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html

sveetch commented 1 year ago

Lotus itself don't directly make usage of pytz, this is only in the tests. zoneinfo seems safe to use since Django 3.2 so we can move to zoneinfo and at least drop Django 3.1 support. In fact Lotus should be safe to run on Django 3.1 except in development mode where there will be usage of zoneinfo directly from tests that will fail.

Here is a grep with silvereacher:

$ ag --python pytz
tests/010_models/013_article.py
5:import pytz
430:    default_tz = pytz.timezone("UTC")
513:    default_tz = pytz.timezone("UTC")

tests/050_views/053_article.py
4:import pytz
295:    default_tz = pytz.timezone("UTC")
464:    default_tz = pytz.timezone("UTC")

tests/050_views/052_author.py
4:import pytz
210:    default_tz = pytz.timezone("UTC")

tests/040_templatetags/041_article_states.py
3:import pytz
41:    default_tz = pytz.timezone("UTC")
80:    default_tz = pytz.timezone("UTC")
120:    default_tz = pytz.timezone("UTC")
158:    default_tz = pytz.timezone("UTC")

tests/040_templatetags/042_translation_siblings.py
4:import pytz
97:    default_tz = pytz.timezone("UTC")
186:    default_tz = pytz.timezone("UTC")
251:    default_tz = pytz.timezone("UTC")

tests/020_managers/022_author.py
3:import pytz
18:    default_tz = pytz.timezone("UTC")
100:    default_tz = pytz.timezone("UTC")

tests/020_managers/023_article.py
3:import pytz
24:    default_tz = pytz.timezone("UTC")
181:    default_tz = pytz.timezone("UTC")
277:    default_tz = pytz.timezone("UTC")

tests/030_admin/032_article.py
4:import pytz
47:    default_tz = pytz.timezone("UTC")

tests/000_base/001_dates.py
3:import pytz
10:    How to make a datetime aware of a specific timezone using pytz.
13:    sandbox_tz = pytz.timezone("Pacific/Chatham")
33:    sandbox_tz = pytz.timezone("Pacific/Chatham")

Also after fix this, we will fix the deprecation warning with settings.USE_L10N that should be safe enough to remove.

sveetch commented 1 year ago

Django 4.0 and 4.1 support are done since 0.5.0-pre.12, Django 3.1 has been dropped.

USE_L10N has been left unchanged for now, need to know if its default value to True is from Django 3.2 or 4.0, only the latter one would allow to remove it.