cleanup
This commit is contained in:
@@ -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")
|
||||
Reference in New Issue
Block a user