MCPcopy Index your code
hub / github.com/encode/django-rest-framework / to_representation

Method to_representation

rest_framework/fields.py:1597–1612  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

1595 return data
1596
1597 def to_representation(self, value):
1598 if not value:
1599 return None
1600
1601 use_url = getattr(self, 'use_url', api_settings.UPLOADED_FILES_USE_URL)
1602 if use_url:
1603 try:
1604 url = value.url
1605 except AttributeError:
1606 return None
1607 request = self.context.get('request', None)
1608 if request is not None:
1609 return request.build_absolute_uri(url)
1610 return url
1611
1612 return value.name
1613
1614
1615class ImageField(FileField):

Calls 2

build_absolute_uriMethod · 0.80
getMethod · 0.45