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 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