From de0746e61e364b5713d42e99b2d0293042b65055 Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Mon, 10 Jun 2024 10:22:40 +0200 Subject: [PATCH] fixed issue with uploading data and saving --- app/general/management/commands/dev_pdf_mass_upload.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/general/management/commands/dev_pdf_mass_upload.py b/app/general/management/commands/dev_pdf_mass_upload.py index 3dbc696e..cb81cf5d 100644 --- a/app/general/management/commands/dev_pdf_mass_upload.py +++ b/app/general/management/commands/dev_pdf_mass_upload.py @@ -82,7 +82,12 @@ def print_error(self): def save_data(self, data): # Generate a random number for the institution ID random_number = random.randint(1, 20) - content_file = ContentFile(data["uploaded_file"], name=data["title"]) + + # Read the uploaded file data + with open(data["uploaded_file"], "rb") as f: + get_content_file = f.read() + + content_file = ContentFile(get_content_file, name=data["title"]) try: document_data = GetTextFromPDF(data["uploaded_file"]).to_text()