From 0e0f0b54b1fff0432db4a78f2a42a0869ee60bc7 Mon Sep 17 00:00:00 2001 From: Alibi Shalgymbay Date: Wed, 6 Oct 2021 00:04:40 +0600 Subject: [PATCH 1/2] Add underscore inflection for included_resources in AutoPrefetchMixin --- rest_framework_json_api/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework_json_api/views.py b/rest_framework_json_api/views.py index c53864a0..197920e0 100644 --- a/rest_framework_json_api/views.py +++ b/rest_framework_json_api/views.py @@ -1,5 +1,6 @@ from collections.abc import Iterable +import inflection from django.core.exceptions import ImproperlyConfigured from django.db.models import Model from django.db.models.fields.related_descriptors import ( @@ -86,6 +87,9 @@ def get_queryset(self, *args, **kwargs): included_resources = get_included_resources( self.request, self.get_serializer_class() ) + included_resources = [ + inflection.underscore(value) for value in included_resources + ] for included in included_resources + ["__all__"]: # If include was not defined, trying to resolve it automatically From 5ecbfa76bc15a7897b32c6ef0d33bb9d823a73a3 Mon Sep 17 00:00:00 2001 From: Alibi Shalgymbay Date: Wed, 6 Oct 2021 00:23:15 +0600 Subject: [PATCH 2/2] Document changes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3011d2e..a2a30b68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ any parts of the framework not mentioned in the documentation should generally b * Adjusted error messages to correctly use capitial "JSON:API" abbreviation as used in the specification. * Avoid error when `parser_context` is `None` while parsing. +* Perform inflection for `included_resources` in `AutoPrefetchMixin` ([#871](https://github.com/django-json-api/django-rest-framework-json-api/issues/871)) ### Changed