mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
Added option to prepend MEDIA_ROOT to FileField fields.
This commit is contained in:
parent
c7a988eb38
commit
4eeb4342dd
|
@ -973,6 +973,8 @@ class FileField(WritableField):
|
|||
return data
|
||||
|
||||
def to_native(self, value):
|
||||
if api_settings.PREPEND_MEDIA_URL:
|
||||
return api_settings.MEDIA_URL + value.name
|
||||
return value.name
|
||||
|
||||
|
||||
|
|
|
@ -119,6 +119,10 @@ DEFAULTS = {
|
|||
|
||||
# Pending deprecation
|
||||
'FILTER_BACKEND': None,
|
||||
|
||||
# Prepending MEDIA_URL to FileField
|
||||
'PREPEND_MEDIA_URL': False,
|
||||
'MEDIA_URL': '/',
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user