Update fields.py

ImageFields can show_urls=True instead of file names
This commit is contained in:
kakulukia 2014-09-19 14:06:33 +02:00
parent 1e9ea377e3
commit aa5809d1b7

View File

@ -988,6 +988,15 @@ class ImageField(FileField):
'invalid_image': _("Upload a valid image. The file you uploaded was "
"either not an image or a corrupted image."),
}
def __init__(self, *args, **kwargs):
self.show_url = kwargs.pop('show_url', False)
super(ImageField, self).__init__(*args, **kwargs)
def to_native(self, value):
if self.show_url:
return value.url
return value.name
def from_native(self, data):
"""