-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fixed #3674 -- Refactored _get_reverse_relationships() to use correct to_field. #3852
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
Changes from 1 commit
ce98c3d
21839e4
dae5a5c
b7b6ba3
15ec87c
e670284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1132,7 +1132,7 @@ def build_relational_field(self, field_name, relation_info): | |
|
|
||
| to_field = field_kwargs.pop('to_field', None) | ||
| if relation_info.reverse: | ||
| if to_field and not relation_info.related_model_field.related_field.primary_key: | ||
| if to_field and not relation_info.related_model_field.related_fields[0][1].primary_key: | ||
| field_kwargs['slug_field'] = to_field | ||
| field_class = self.serializer_related_to_field | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests don't appear to hit this branch, so hard to verify on first sight - some more digging may be required. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it looks like we need to add a test case where the |
||
| else: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea what the
[0][1]refers to here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will need to go back in and check what the actual values are. I really should have put a comment in there when I made the change. I'm pretty sure it's grabbing the
to_fieldvalue for the related field (see the relevant django code here) but you are totally right, it is very hard to decipher just by looking at it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related_fields[0]is the first field in the model'sfrom_fieldslist; it's a tuple of(from_field, to_field)so[1]here is referring toto_field