Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c93dea1

Browse files
birkholzjerel
authored andcommitted
Convert includes from camel to snake case (#257)
1 parent bd4b64e commit c93dea1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

‎rest_framework_json_api/renderers.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import copy
55
from collections import OrderedDict
66

7+
import inflection
78
from django.utils import six, encoding
89
from rest_framework import relations
910
from rest_framework import renderers
@@ -237,6 +238,7 @@ def extract_included(fields, resource, resource_instance, included_resources):
237238
context = current_serializer.context
238239
included_serializers = utils.get_included_serializers(current_serializer)
239240
included_resources = copy.copy(included_resources)
241+
included_resources = [inflection.underscore(value) for value in included_resources]
240242

241243
for field_name, field in six.iteritems(fields):
242244
# Skip URL field

‎rest_framework_json_api/serializers.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import inflection
12
from django.utils.translation import ugettext_lazy as _
23
from rest_framework.exceptions import ParseError
34
from rest_framework.serializers import *
@@ -75,7 +76,7 @@ def validate_path(serializer_class, field_path, path):
7576
serializers = get_included_serializers(serializer_class)
7677
if serializers is None:
7778
raise ParseError('This endpoint does not support the include parameter')
78-
this_field_name = field_path[0]
79+
this_field_name = inflection.underscore(field_path[0])
7980
this_included_serializer = serializers.get(this_field_name)
8081
if this_included_serializer is None:
8182
raise ParseError(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /