Skip to content

Commit

Permalink
Merge pull request #20 from RudolfCardinal/django-4.2
Browse files Browse the repository at this point in the history
Fixes for Django 4.2
  • Loading branch information
martinburchell authored Jul 15, 2024
2 parents d56e383 + e6f6db5 commit bf91428
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
5 changes: 1 addition & 4 deletions cardinal_pythonlib/django/fields/isodatetimetz.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
# noinspection PyUnresolvedReferences
from django.db.models.fields import DateField, DateTimeField, Field

# noinspection PyUnresolvedReferences
from django.utils import timezone

from cardinal_pythonlib.logs import get_brace_style_log_with_null_handler

log = get_brace_style_log_with_null_handler(__name__)
Expand Down Expand Up @@ -256,7 +253,7 @@ def get_prep_value(self, value):
# function must always return a string type.
# https://docs.djangoproject.com/en/1.8/howto/custom-model-fields/
# Convert to UTC
return value.astimezone(timezone.utc)
return value.astimezone(datetime.timezone.utc)

def get_db_prep_value(self, value, connection, prepared=False):
"""
Expand Down
6 changes: 3 additions & 3 deletions cardinal_pythonlib/django/fields/restrictedcontentfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
from django.template.defaultfilters import filesizeformat

# noinspection PyUnresolvedReferences
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext_lazy


# =============================================================================
Expand Down Expand Up @@ -96,7 +96,7 @@ def clean(self, *args, **kwargs) -> Any:
content_type = f.content_type
if content_type not in self.content_types:
raise forms.ValidationError(
ugettext_lazy("Filetype not supported.")
gettext_lazy("Filetype not supported.")
)
if hasattr(f, "size"): # e.g. Django 2.1.2
uploaded_file_size = f.size
Expand All @@ -110,7 +110,7 @@ def clean(self, *args, **kwargs) -> Any:
and uploaded_file_size > self.max_upload_size
):
raise forms.ValidationError(
ugettext_lazy(
gettext_lazy(
"Please keep filesize under %s. Current filesize %s"
)
% (
Expand Down
9 changes: 9 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Quick links:
- :ref:`2020 <changelog_2020>`
- :ref:`2021 <changelog_2021>`
- :ref:`2022 <changelog_2022>`
- :ref:`2023 <changelog_2023>`
- :ref:`2024 <changelog_2024>`


.. _changelog_2017:
Expand Down Expand Up @@ -792,10 +794,17 @@ Quick links:

- Supported SQLAlchemy version now 1.4

.. _changelog_2024:

**1.1.26 (2024-03-03)**

- Fix ``AttributeError: 'Engine' object has no attribute 'schema_for_object'``
when adding a full text index to an anonymised SQL Server database table.
This bug has been present since the SQLAlchemy 1.4 upgrade in 1.1.25.

**1.1.27 (in progress)**

- Fixes for Django 4.

- Replace ugettext_* calls removed in Django 4.0.
https://docs.djangoproject.com/en/4.2/releases/4.0/#features-removed-in-4-0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
# bcrypt
# colander
# deform
# Django>=2.0.0
# Django>=4.2
# dogpile.cache
# pyramid
# webob # installed by pyramid
Expand Down

0 comments on commit bf91428

Please sign in to comment.