mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-05 04:50:12 +03:00
ability to use other domain than currently used
This commit is contained in:
parent
de08f28a91
commit
c375877ab6
|
@ -1408,6 +1408,7 @@ class FileField(Field):
|
||||||
self.allow_empty_file = kwargs.pop('allow_empty_file', False)
|
self.allow_empty_file = kwargs.pop('allow_empty_file', False)
|
||||||
if 'use_url' in kwargs:
|
if 'use_url' in kwargs:
|
||||||
self.use_url = kwargs.pop('use_url')
|
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)
|
super(FileField, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
|
@ -1438,6 +1439,8 @@ class FileField(Field):
|
||||||
# If the file has not been saved it may not have a URL.
|
# If the file has not been saved it may not have a URL.
|
||||||
return None
|
return None
|
||||||
url = value.url
|
url = value.url
|
||||||
|
if self.url_prefix:
|
||||||
|
url = self.url_prefix + url
|
||||||
request = self.context.get('request', None)
|
request = self.context.get('request', None)
|
||||||
if request is not None:
|
if request is not None:
|
||||||
return request.build_absolute_uri(url)
|
return request.build_absolute_uri(url)
|
||||||
|
|
|
@ -111,6 +111,7 @@ DEFAULTS = {
|
||||||
'COMPACT_JSON': True,
|
'COMPACT_JSON': True,
|
||||||
'COERCE_DECIMAL_TO_STRING': True,
|
'COERCE_DECIMAL_TO_STRING': True,
|
||||||
'UPLOADED_FILES_USE_URL': True,
|
'UPLOADED_FILES_USE_URL': True,
|
||||||
|
'UPLOADED_FILES_URL_PREFIX': None,
|
||||||
|
|
||||||
# Browseable API
|
# Browseable API
|
||||||
'HTML_SELECT_CUTOFF': 1000,
|
'HTML_SELECT_CUTOFF': 1000,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user