summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/widgets.py15
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: