Skip to content
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

Fixed #3674 -- Refactored _get_reverse_relationships() to use correct to_field. #3852

Closed
wants to merge 6 commits into from

Conversation

xordoquy
Copy link
Collaborator

overtakes #3696 (thanks to @benred42) !

@jpadilla
Copy link
Member

geez you're on fire 🔥 😄

@xordoquy
Copy link
Collaborator Author

@jpadilla trying to get things moving. ATM Travis is on fire

Otherwise we'll get a conflict between tests.test_model_serializer.ParentModel and tests.test_multitable_inheritance.ParentModel.
@xordoquy
Copy link
Collaborator Author

And there we are.

@jpadilla
Copy link
Member

LGTM 👍

@beaugunderson
Copy link

👍 as well; I was the original reporter of this issue and can verify that it works for me. :)

@tomchristie
Copy link
Member

Closes #3674.

field_kwargs['slug_field'] = to_field
field_class = self.serializer_related_to_field
if relation_info.reverse:
if to_field and not relation_info.related_model_field.related_fields[0][1].primary_key:
Copy link
Member

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?

Copy link

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_field value 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.

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's from_fields list; it's a tuple of (from_field, to_field) so [1] here is referring to to_field

@tomchristie tomchristie modified the milestones: 3.4.7 Release, 3.4.8 Release Sep 21, 2016
@tomchristie tomchristie modified the milestones: 3.4.8 Release, 3.5.1 Release Sep 30, 2016
@tomchristie tomchristie changed the title Fixed #3674 -- Refactored _get_reverse_relationships() to use correct to_field (overtake #3696) Fixed #3674 -- Refactored _get_reverse_relationships() to use correct to_field. Oct 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants