Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inflection for AutoPrefetchMixin #990

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions rest_framework_json_api/views.py
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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
Expand Down