From e471b57ec3327835088a14532e917b7664da7c25 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 16 Feb 2021 10:29:04 +0000 Subject: [PATCH] cleanup --- core/management/commands/addtestdata.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/core/management/commands/addtestdata.py b/core/management/commands/addtestdata.py index 2d98449..7d98462 100644 --- a/core/management/commands/addtestdata.py +++ b/core/management/commands/addtestdata.py @@ -77,28 +77,13 @@ class Command(BaseCommand): response.raw.decode_content = True image = Image.open(response.raw) - + # save using File object img_io = BytesIO() image.save(img_io, format='JPEG') - # option 1: read image from memory - ''' - product.image = InMemoryUploadedFile( - BytesIO(), - field_name=None, - name=f"{company.company_name}-{name}.jpg", - content_type='image/jpeg', - size=img_io.tell, - charset=None - ) - ''' - # option 2: File object - product.image.save(f"{company.company_name}-{name}.jpg", File(img_io), save=False) product.save() logging.debug(f"New Product {product.name} created") - print("*", end = '.') - # import ipdb; ipdb.set_trace() print('') print("Dataset creation finished") \ No newline at end of file