diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 13b15314..f49ba833 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -12,9 +12,9 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.9, "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] dj-version: ["3.0.*", "3.1.*", "3.2.*", "4.0.*", "4.1.*", "4.2.*", "5.0.*", "5.1.*", "5.2.*"] - drf-version: ["3.11.*", "3.12.*", "3.13.*", "3.14.*", "3.15.*"] + drf-version: ["3.11.*", "3.12.*", "3.13.*", "3.14.*", "3.15.*", "3.16.*"] exclude: - dj-version: '4.0.*' drf-version: '3.11.*' @@ -36,8 +36,6 @@ jobs: python-version: 3.9 - dj-version: '5.1.*' python-version: 3.9 - - dj-version: '5.2.*' - python-version: 3.9 - dj-version: '5.0.*' drf-version: '3.11.*' - dj-version: '5.0.*' @@ -56,6 +54,8 @@ jobs: drf-version: '3.12.*' - dj-version: '5.2.*' drf-version: '3.13.*' + - dj-version: '5.2.*' + drf-version: '3.16.*' - python-version: 3.12 dj-version: '3.0.*' - python-version: 3.12 diff --git a/README.md b/README.md index 531f8484..84c389ee 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ over HTTP. - Python (3.9, 3.10, 3.11, 3.12) - Django (3.1, 3.2, 4.0, 4.1, 4.2, 5.0, 5.1) -- Django REST Framework (3.11, 3.12, 3.13, 3.14, 3.15) +- Django REST Framework (3.11, 3.12, 3.13, 3.14, 3.15, 3.16) # Installation @@ -649,7 +649,7 @@ We actively support the following: - Python: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 - Django: 2.2, 3.1, 3.2, 4.0, 4.1, 4.2, 5.0, 5.1 -- Django Rest Framework: 3.11, 3.12, 3.13, 3.14, 3.15 +- Django Rest Framework: 3.11, 3.12, 3.13, 3.14, 3.15, 3.16 **Note:** Some combinations are not supported. For up-to-date information on actively supported/tested combinations, see the `tox.ini` file. diff --git a/README.rst b/README.rst index a54ab4de..9d6acf16 100644 --- a/README.rst +++ b/README.rst @@ -46,4 +46,4 @@ Requirements - Python (3.9, 3.10, 3.11, 3.12) - Django (3.1, 3.2, 4.0, 4.1, 4.2, 5.0, 5.1) -- Django REST Framework (3.11, 3.12, 3.13, 3.14, 3.15) +- Django REST Framework (3.11, 3.12, 3.13, 3.14, 3.15, 3.16) diff --git a/dynamic_rest/__init__.py b/dynamic_rest/__init__.py index 49959bdc..d7e5bef3 100644 --- a/dynamic_rest/__init__.py +++ b/dynamic_rest/__init__.py @@ -8,5 +8,6 @@ - Directory panel for the browsable API - Optimizations """ -__version__ = "2.5.1" + +__version__ = "2.5.3" default_app_config = "dynamic_rest.apps.DynamicRestConfig" diff --git a/dynamic_rest/filters/base.py b/dynamic_rest/filters/base.py index 90d69e9f..b827819b 100644 --- a/dynamic_rest/filters/base.py +++ b/dynamic_rest/filters/base.py @@ -102,6 +102,7 @@ class DynamicFilterBackend(BaseFilterBackend): This backend is responsible for interpreting and applying filters, includes, and excludes to the base queryset of a view. """ + DISABLE_PREFETCHING = False def filter_queryset(self, request: Request, queryset: QuerySet, view) -> QuerySet: """Filter the queryset. @@ -119,7 +120,7 @@ def filter_queryset(self, request: Request, queryset: QuerySet, view) -> QuerySe # after this is called may not behave as expected extra_filters = self.view.get_extra_filters(request) - disable_prefetches = self.view.is_update() + disable_prefetches = self.view.is_update() or self.DISABLE_PREFETCHING return self._build_queryset( queryset=queryset, @@ -391,14 +392,14 @@ def _build_queryset( if filters is None: filters = _get_requested_filters(getattr(self, "view", None)) - # build nested Prefetch queryset - self._build_requested_prefetches( - prefetches, requirements, model, fields, filters - ) - - # build remaining prefetches out of internal requirements - # that are not already covered by request requirements - self._build_implicit_prefetches(model, prefetches, requirements) + if not disable_prefetches: + # build nested Prefetch queryset + self._build_requested_prefetches( + prefetches, requirements, model, fields, filters + ) + # build remaining prefetches out of internal requirements + # that are not already covered by request requirements + self._build_implicit_prefetches(model, prefetches, requirements) # use requirements at this level to limit fields selected # only do this for GET requests where we are not requesting the @@ -461,3 +462,14 @@ def _build_queryset( if DEBUG: queryset._using_prefetches = prefetches # pylint: disable=protected-access return queryset + + +class DynamicFilterNoPrefetchBackend(DynamicFilterBackend): + """ + A DRF filter backend that constructs DREST QuerySets without prefetching. + + This backend is responsible for interpreting and applying + filters, includes, and excludes to the base queryset of a view. + """ + + DISABLE_PREFETCHING = True diff --git a/install_requires.txt b/install_requires.txt index e61a3f4a..2015bb31 100644 --- a/install_requires.txt +++ b/install_requires.txt @@ -1,5 +1,5 @@ Django>=3.2,<5.3 -djangorestframework>=3.11.2,<3.16 +djangorestframework>=3.11.2,<3.17 inflection>=0.5.0 requests sqids>=0.1.0 diff --git a/requirements.txt b/requirements.txt index 0e79a68d..7a93e319 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ tox==4.11.3 twine==4.0.2 inflection==0.5.1 Django>=3.2,<5.3 -djangorestframework>=3.11.2,<3.16 +djangorestframework>=3.11.2,<3.17 orjson>=3.9.7 black==23.9.1 isort==5.12.0 diff --git a/setup.py b/setup.py index 895e7ffa..6c1bf30d 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,11 @@ """Setup script for dynamic-rest-bse.""" + from setuptools import find_packages, setup NAME = "dynamic-rest-bse" DESCRIPTION = "Dynamic API support to Django REST Framework. Forked..." URL = "http://github.com/BillSchumacher/dynamic-rest" -VERSION = "2.5.1" +VERSION = "2.5.3" SCRIPTS = ["manage.py"] with open("install_requires.txt", encoding="utf-8") as fp: