-
Notifications
You must be signed in to change notification settings - Fork 299
Commit 9d11e8a
Fix related resource on inherited polymorphic model (#767)
Fixes #621
When adding a ResourceRelatedField to a serializer that is included in the polymorphic_serializers
list of a polymorphic serializer, the parent_model is not correctly resolved in get_related_resource_type: instead of resolving to the inherited type, the base type is resolved. This can cause an AttributeError if the field in question is not present on the base model.
We ran into this, and then found the closed and seemingly abandoned issue referenced above. This PR implements the fix suggested by the original author, who deserves all the credit. The example code has been expanded to trigger the error when running the test-suite.
Thanks in advance for your time and please let us know if you have any suggestions for improvement.1 parent c8c5cf1 commit 9d11e8a
File tree
6 files changed
+47
-1
lines changed- example
- migrations
- rest_framework_json_api
6 files changed
+47
-1
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
30 | + |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
21 | 21 |
| |
22 | 22 |
| |
23 | 23 |
| |
24 | + | ||
24 | 25 |
| |
25 | 26 |
| |
26 | 27 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | + | ||
2 | + | ||
3 | + | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
9 | + | ||
10 | + | ||
11 | + | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | + | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | + | ||
23 | + |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
151 | 151 |
| |
152 | 152 |
| |
153 | 153 |
| |
154 | + | ||
155 | + | ||
156 | + | ||
157 | + | ||
158 | + | ||
159 | + | ||
160 | + | ||
154 | 161 |
| |
155 | 162 |
| |
156 | 163 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 | + | ||
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
| |||
303 | 304 |
| |
304 | 305 |
| |
305 | 306 |
| |
307 | + | ||
308 | + | ||
309 | + | ||
306 | 310 |
| |
307 | 311 |
| |
308 | 312 |
| |
309 | 313 |
| |
310 | 314 |
| |
315 | + | ||
316 | + | ||
317 | + | ||
318 | + | ||
319 | + | ||
320 | + | ||
311 | 321 |
| |
312 | 322 |
| |
313 | 323 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
143 | 143 |
| |
144 | 144 |
| |
145 | 145 |
| |
146 | + | ||
146 | 147 |
| |
147 | 148 |
| |
148 | 149 |
| |
| |||
165 | 166 |
| |
166 | 167 |
| |
167 | 168 |
| |
168 | - | ||
169 | + | ||
170 | + | ||
171 | + | ||
172 | + | ||
169 | 173 |
| |
170 | 174 |
| |
171 | 175 |
| |
|
0 commit comments