mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
Merge c375877ab6
into a251b93792
This commit is contained in:
commit
d0b9a22479
|
@ -1435,6 +1435,7 @@ class FileField(Field):
|
|||
self.allow_empty_file = kwargs.pop('allow_empty_file', False)
|
||||
if 'use_url' in kwargs:
|
||||
self.use_url = kwargs.pop('use_url')
|
||||
self.url_prefix = kwargs.pop('url_prefix', api_settings.UPLOADED_FILES_URL_PREFIX)
|
||||
super(FileField, self).__init__(*args, **kwargs)
|
||||
|
||||
def to_internal_value(self, data):
|
||||
|
@ -1465,6 +1466,8 @@ class FileField(Field):
|
|||
# If the file has not been saved it may not have a URL.
|
||||
return None
|
||||
url = value.url
|
||||
if self.url_prefix:
|
||||
url = self.url_prefix + url
|
||||
request = self.context.get('request', None)
|
||||
if request is not None:
|
||||
return request.build_absolute_uri(url)
|
||||
|
|
|
@ -112,6 +112,7 @@ DEFAULTS = {
|
|||
'COMPACT_JSON': True,
|
||||
'COERCE_DECIMAL_TO_STRING': True,
|
||||
'UPLOADED_FILES_USE_URL': True,
|
||||
'UPLOADED_FILES_URL_PREFIX': None,
|
||||
|
||||
# Browseable API
|
||||
'HTML_SELECT_CUTOFF': 1000,
|
||||
|
|
Loading…
Reference in New Issue
Block a user