From 791eb63f35dada65aff33714e50d0c08d7a5579b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 5 Apr 2020 22:59:45 +1000 Subject: [PATCH] Same fix for Part API --- InvenTree/part/api.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index e032c73eeb..9b73f68973 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -225,11 +225,17 @@ class PartList(generics.ListCreateAPIView): # Use the 'thumbnail' image here instead of the full-size image # Note: The full-size image is used when requesting the /api/part// endpoint - fn, ext = os.path.splitext(img) - thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext) + if img: + fn, ext = os.path.splitext(img) - item['thumbnail'] = os.path.join(settings.MEDIA_URL, thumb) + thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext) + + thumb = os.path.join(settings.MEDIA_URL, thumb) + else: + thumb = '' + + item['thumbnail'] = thumb del item['image']