diff options
| author | Tom Christie | 2014-10-08 16:59:52 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-10-08 16:59:52 +0100 |
| commit | 5ead8dc89d1a99d6189170dc8dac19cdc8ba7750 (patch) | |
| tree | fb6dd48b39ff2000f69d28524c6748725d329668 /rest_framework/fields.py | |
| parent | 4c015df28cfb7dc7cf29f6dc4985c57e1f5cdc5d (diff) | |
| download | django-rest-framework-5ead8dc89d1a99d6189170dc8dac19cdc8ba7750.tar.bz2 | |
Support empty file fields
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5fb0ec8d..f86f6626 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -913,6 +913,8 @@ class FileField(Field): def to_representation(self, value): if self.use_url: + if not value: + return None url = settings.MEDIA_URL + value.url request = self.context.get('request', None) if request is not None: |
