From 45b6cbc8fb5146cd6de088edb08ea6f9771940d6 Mon Sep 17 00:00:00 2001 From: Chris Muthig Date: Thu, 1 May 2025 15:03:17 -0600 Subject: [PATCH] Add support for Django 5 A new cached property called `accessor_name` was added in 5.2 for performance improvements that this package needs to mimic. This uses the same value as `get_accessor_name`, which is how it is also implemented in core. See: https://code.djangoproject.com/ticket/35230 --- .github/workflows/tests.yml | 8 +++++++- relativity/fields.py | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0518fb9..c941ba5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: - postgres://postgres:postgres@postgres/django_relativity - sqlite:// - mysql://root:mysql@mysql/django_relativity - django_version: ["3.2", "4.0", "4.1", "4.2"] + django_version: ["3.2", "4.0", "4.1", "4.2", "5.0", "5.1", "5.2"] python_version: ["3.8", "3.9", "3.10", "3.11"] include: - {django_version: "3.2", python_version: "3.6", database_url: "postgres://postgres:postgres@postgres/django_relativity"} @@ -23,6 +23,12 @@ jobs: exclude: - {django_version: "3.2", python_version: "3.11"} - {django_version: "4.0", python_version: "3.11"} + - {django_version: "5.0", python_version: "3.8"} + - {django_version: "5.0", python_version: "3.9"} + - {django_version: "5.1", python_version: "3.8"} + - {django_version: "5.1", python_version: "3.9"} + - {django_version: "5.2", python_version: "3.8"} + - {django_version: "5.2", python_version: "3.9"} runs-on: ubuntu-latest container: python:${{ matrix.python_version }} steps: diff --git a/relativity/fields.py b/relativity/fields.py index f527260..75d4993 100644 --- a/relativity/fields.py +++ b/relativity/fields.py @@ -360,6 +360,10 @@ def field(self): """ return self.remote_field + @cached_property + def accessor_name(self): + return self.get_accessor_name() + def get_accessor_name(self): return self.name