Skip to content
Merged
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
same logic, more pythonic
  • Loading branch information
Martin Hill committed Nov 15, 2015
commit ff36cbe4baa50302aa566c1d188a5f98393fd895
2 changes: 1 addition & 1 deletion rest_framework/utils/model_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _get_fields(opts):


def _get_to_field(field):
return field.to_fields[0] if hasattr(field, 'to_fields') and field.to_fields else None
return getattr(field, 'to_fields', None) and field.to_fields[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we us hasattr instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

@tomchristie no, cf my previous outdated comment

Copy link
Contributor

Choose a reason for hiding this comment

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

Ack - ignore my comment there. Incorrect.



def _get_forward_relationships(opts):
Expand Down