Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
* Removed 2 unnecessary lines
  • Loading branch information
Harper04 committed Jan 19, 2015
commit 6369f93d041e1879ca8ef05f0fd8fe4875fc9360
4 changes: 1 addition & 3 deletions rest_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,13 +1004,11 @@ def get_fields(self):
kwargs = get_nested_relation_kwargs(relation_info)
else:
kwargs = get_relation_kwargs(field_name, relation_info)
to_field = kwargs.get('to_field', False)
kwargs.pop('to_field', None)
to_field = kwargs.pop('to_field', None)
# it seems that some tests/django initializers are setting
# to_field where it is totally unnecessary
if to_field and to_field != 'id':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary key may not be named 'id' so I'm unsure about this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see 2 (outdated diffs) above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some clarification on this? The comment is a bit vauge about what the issue actually is, though I assume it has to do with AutoField considering it involves the id field?

I understand the point of doing if to_field, not the additional check though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it also has to do with what gets into that to_field and makes it to that point. I would remove any 'id' entries in compat/get_to_field making this check here unnecessary. Maybe not the best solution but the to_field irritates me for now. I think for plain ForeignKeys it is safe but for anything else... i dont know.

I added some links to the core issue of that 2 posts above. Thats what i meant.

# using the slug field for now
kwargs.pop('to_field', None)
kwargs['slug_field'] = to_field
field_cls = self._related_to_field_class
else:
Expand Down