Skip to content

Commit c262e77

Browse files
committedSep 17, 2015
Fix camelcase -> dasherise issue
Work around the fact that inflection.dasherise does only work from the underscored state Referring to 5b64567#commitcomment-13266779
1 parent 8d4131b commit c262e77

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎rest_framework_json_api/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ def format_value(value, format_type=None):
132132
def format_relation_name(value, format_type=None):
133133
if format_type is None:
134134
format_type = getattr(settings, 'JSON_API_FORMAT_RELATION_KEYS', False)
135+
136+
if not format_type:
137+
# let's keep it the way it was
138+
return value
139+
140+
# in case the value is going to be changed, make it underscored first
141+
# because dasherize does not work with a camel cased string
142+
value = inflection.underscore(value)
135143

136144
# format_type will never be None here so we can use format_value
137145
value = format_value(value, format_type)

0 commit comments

Comments
 (0)
Please sign in to comment.