Skip to content
Closed
Changes from all commits
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
Not all File Objects have a .url attribute
  • Loading branch information
ar45 committed Mar 24, 2015
commit 010db598f63758fa5fa4a7d9238092d299853a00
2 changes: 1 addition & 1 deletion rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ def to_internal_value(self, data):
return data

def to_representation(self, value):
if self.use_url:
if self.use_url and hasattr(value, 'url'):
if not value:
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this if not value check should be moved to the top of the method instead of being hidden away here.

Copy link
Contributor

Choose a reason for hiding this comment

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

True.

return None
url = value.url
Expand Down