Prevent empty file name

This commit is contained in:
Joachim 2021-11-20 17:10:29 +01:00
parent d74df047c5
commit f26a41bd10

View file

@ -323,6 +323,9 @@ def save_and_cleanup(image, instance=None):
try:
file_name = instance.preview_image.name
except ValueError:
file_name = None
if not file_name or file_name == '':
uuid = uuid4()
file_name = f"{instance.id}-{uuid}.jpg"