From 53a22853c5cb1ab235fbd191215f88a66708c7b4 Mon Sep 17 00:00:00 2001 From: Henri Dickson <90480431+alphatownsman@users.noreply.github.com> Date: Mon, 11 Aug 2025 08:18:50 -0400 Subject: [PATCH] upgrade to django 5.2 --- hatchway/http.py | 18 ++++++++++-------- pyproject.toml | 2 +- requirements-dev.lock | 2 +- requirements.lock | 2 +- takahe/settings.py | 4 ++-- tests/conftest.py | 3 +++ 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/hatchway/http.py b/hatchway/http.py index 64d4f174..6c6fc142 100644 --- a/hatchway/http.py +++ b/hatchway/http.py @@ -3,6 +3,7 @@ from django.core.serializers.json import DjangoJSONEncoder from django.http.response import HttpResponseBase +from django.utils.functional import cached_property T = TypeVar("T") @@ -25,19 +26,20 @@ def __init__( self.data = data self.encoder = encoder self.json_dumps_params = json_dumps_params or {} - self.json_bytes = None kwargs.setdefault("content_type", "application/json") super().__init__(**kwargs) @property def content(self): - if self.json_bytes is None: - self.json_bytes = json.dumps( - self.data, - cls=self.encoder, - **self.json_dumps_params, - ).encode("utf-8") - return self.json_bytes + return self.text.encode("utf-8") + + @cached_property + def text(self): + return json.dumps( + self.data, + cls=self.encoder, + **self.json_dumps_params, + ) def __iter__(self): yield self.content diff --git a/pyproject.toml b/pyproject.toml index 22d0a898..e394df98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ dependencies = [ "cachetools>=5.3.3", "cryptography>=42.0.5", "dj-database-url>=2.1.0", - "django~=4.2.0", + "django~=5.2.0", "django-cache-url>=3.4.5", "django-cors-headers>=4.3.1", "django-debug-toolbar>=4.3.0", diff --git a/requirements-dev.lock b/requirements-dev.lock index e3aabc04..18e07fa2 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -21,7 +21,7 @@ colorama==0.4.6 ; sys_platform == 'win32' cryptography==45.0.2 distlib==0.3.9 dj-database-url==2.3.0 -django==4.2.21 +django==5.2.6 django-cache-url==3.4.5 django-cors-headers==4.7.0 django-debug-toolbar==5.2.0 diff --git a/requirements.lock b/requirements.lock index 5ea38afd..d5850b79 100644 --- a/requirements.lock +++ b/requirements.lock @@ -19,7 +19,7 @@ click==8.2.1 colorama==0.4.6 ; sys_platform == 'win32' cryptography==45.0.2 dj-database-url==2.3.0 -django==4.2.21 +django==5.2.6 django-cache-url==3.4.5 django-cors-headers==4.7.0 django-debug-toolbar==5.2.0 diff --git a/takahe/settings.py b/takahe/settings.py index dae75126..bd797045 100644 --- a/takahe/settings.py +++ b/takahe/settings.py @@ -347,8 +347,8 @@ class Settings(BaseSettings): ROBOTS_TXT_DISALLOWED_USER_AGENTS = SETUP.ROBOTS_TXT_DISALLOWED_USER_AGENTS -CORS_ORIGIN_ALLOW_ALL = True # Temporary -CORS_ORIGIN_WHITELIST = SETUP.CORS_HOSTS +CORS_ALLOW_ALL_ORIGINS = True # Temporary +CORS_ALLOWED_ORIGINS = SETUP.CORS_HOSTS CORS_ALLOW_CREDENTIALS = True CORS_PREFLIGHT_MAX_AGE = 604800 CORS_EXPOSE_HEADERS = ("link",) diff --git a/tests/conftest.py b/tests/conftest.py index b021f382..de5b271c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -64,6 +64,9 @@ def _test_settings(settings): "staticfiles": { "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage" }, + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, } settings.SETUP.MAIN_DOMAIN = "example.com" settings.MAIN_DOMAIN = "example.com"