Added option to prepend MEDIA_ROOT to FileField fields.

This commit is contained in:
Mihail Burduja 2014-07-28 20:41:19 +03:00
parent c7a988eb38
commit 4eeb4342dd
2 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -119,6 +119,10 @@ DEFAULTS = {
# Pending deprecation
'FILTER_BACKEND': None,
# Prepending MEDIA_URL to FileField
'PREPEND_MEDIA_URL': False,
'MEDIA_URL': '/',
}