diff options
-rw-r--r-- | ishtar_common/widgets.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index b13e9fe2e..14d153651 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -421,11 +421,16 @@ class ImageFileInput(ClearableFileInput): if self.is_initial(value): return value # try to display posted images - if hasattr(value, 'file'): - full_path = str(value.file) - if full_path.startswith(settings.MEDIA_ROOT): - value.url = settings.MEDIA_URL + full_path[ - len(settings.MEDIA_ROOT):] + try: + has_file = hasattr(value, 'file') + except ValueError: + has_file = False + if has_file: + if hasattr(value, 'file'): + full_path = str(value.file) + if full_path.startswith(settings.MEDIA_ROOT): + value.url = settings.MEDIA_URL + full_path[ + len(settings.MEDIA_ROOT):] elif value: full_path = settings.MEDIA_ROOT + str(value) try: |