问题 我需要从excel文件和包含图像的文件夹中导入一些数据，excel中的每一行都描述了每个条目，并且在该文件夹中有一个文件名列表（与条目相关的照片）。 我已经完成了一个脚本，该脚本在数据库中创建每个条目并通过django shell将其保存，但是我不知道如何实例化InMemoryUploadedFile并将其与模型一起保存。 在django 1.0中，我有一个小类，可以让我做我需要做的事，但是随着django 1.1中的更改，它不再起作用了。 class ImportFile(file): def __init__(self, *args, **kwargs): super(ImportFile, self).__init__(*args, **kwargs) self._file = self self.size = os.path.getsize(self.name) def __len__(self): return self.size def chunks(self, chunk_size=None): self._file.seek(0) yield self.read() 我在这段代码中使用了此类，以加载图像并将其与模型实例一起保存。 for photo in photos: f = ImportFile(os.path.join(IMPORT_DIR,
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, self).__init
When deploying applications, I often use Hibernate’s capacity to create database schema in order to simplify the deployment. This is easily achievable by configuring hibernate.hbm2ddl.auto property. However, on occasion I also need to insert some initial data to database, for example root user. Is there a way I could achieve this via hibernate with some kind of load textual file? I know I could easily program the code that will do so, but just wondering if there is already some utility that can help me achieve the same via configuration?