Hi so i am trying to insert images to my database though the shell, but keep on getting this error. Please help
import pandas as pd
from testing.models import retailer
from django.core.files import File
R = pd.read_json("Sample.json")
Title = R["title"].tolist()
Shop = R["shop"].tolist()
Country = R["country"].tolist()
Images = R["images"].tolist()
i = 1
for title,country,shop,images in zip(Title,Shop,Country,Images):
A = images.replace("\\x","")
binary_data = bytes.fromhex(A)
K = retailer(title = title,country = country , shop = shop)
K.image.save(f'{i}-{title}.jpg', File(open(binary_data, 'rb')))
i+=1
ValueError: embedded null byte
THE FULL ERROR :
ValueError Traceback (most recent call last)
<ipython-input-8-34e8d0f9a4fb> in <module>
3 binary_data = bytes.fromhex(A)
4 K = retailer(title = title,country = country , shop = shop)
----> 5 K.image.save(f'{i}-{title}.jpg', File(open(binary_data, 'rb')))
6 i+=1
7
ValueError: embedded null byte
In [9]: