File tree Expand file tree Collapse file tree 1 file changed +55
-1
lines changed Expand file tree Collapse file tree 1 file changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ If you set the `resource_name` property on the object to `False` the data
5555will be returned without modification.
5656
5757
58- ### Inflecting object keys
58+ ### Inflecting object and relation keys
5959
6060This package includes the ability (off by default) to automatically convert json
6161requests and responses from the python/rest_framework's preferred underscore to
@@ -120,6 +120,60 @@ Example - With format conversion set to `dasherize`:
120120}
121121```
122122
123+ #### Relationship types
124+
125+ A similar option to JSON\_ API\_ FORMAT\_ KEYS can be set for the relationship names:
126+
127+ ``` python
128+ JSON_API_FORMAT_RELATION_KEYS = ' dasherize'
129+ ```
130+
131+ Example without format conversion:
132+
133+ ``` js
134+ {
135+ " data" : [{
136+ " type" : " identities" ,
137+ " id" : 3 ,
138+ " attributes" : {
139+ ...
140+ },
141+ " relationships" : {
142+ " home_town" : {
143+ " data" : [{
144+ " type" : " home_town" ,
145+ " id" : 3
146+ }]
147+ }
148+ }
149+ }]
150+ }
151+ ```
152+
153+ When set to dasherize:
154+
155+
156+ ``` js
157+ {
158+ " data" : [{
159+ " type" : " identities" ,
160+ " id" : 3 ,
161+ " attributes" : {
162+ ...
163+ },
164+ " relationships" : {
165+ " home_town" : {
166+ " data" : [{
167+ " type" : " home-town" ,
168+ " id" : 3
169+ }]
170+ }
171+ }
172+ }]
173+ }
174+ ```
175+
176+
123177<!--
124178### Relationships
125179### Links
You can’t perform that action at this time.
0 commit comments