天道酬勤,学无止境

data-importer

“Upload” a file from django shell

Question I need to import some data from a excel file and a folder with images, every row in the excel describes every entry and have a list of filenames in the folder (photos related to the entry). I've done a script which creates every entry in the database and saves it trough the django shell, but i have no idea how to instantiate a InMemoryUploadedFile for save it with the model. In django 1.0 I had this small class which allowed me to do what i need, but with changes in django 1.1 it's not working any more. class ImportFile(file): def __init__(self, *args, **kwargs): super(ImportFile

2021-05-17 14:25:14    分类:技术分享    python   django   file   import   data-importer