def importPDF(self, file_path, filename): filename_split = filename.split("_") school_id = filename_split[0] language = filename_split[2].split(".")[0] school = School.objects.get(pk=school_id) mr = MeetingReport() mr.school = school mr.language = language fil = open(file_path) django_file = File(fil) mr.pdf.save(filename, django_file, save=True) mr.save()
def importPDF(self, file_path, filename): filepath_split = file_path.split('/') filename_split = filename.rstrip('.pdf').split("_") school_id = filename_split[1] language = filepath_split[4] #6 school = School.objects.get(pk=school_id) mr = MeetingReport() mr.school = school mr.language = language generated = Date() mr.generated_at = generated.get_datetime(filepath_split[2] + '-' + filepath_split[3] + '-1') #fil = open(file_path) #django_file = File(fil) #mr.pdf.save(file_path, django_file, save=True) mr.pdf.name = file_path.split('/', 1)[1] mr.save()
def importPDF(self, file_path, filename): filepath_split = file_path.split('/') filename_split = filename.rstrip('.pdf').split("_") school_id = filename_split[1] language = filepath_split[4] #6 school = School.objects.get(pk=school_id) mr = MeetingReport() mr.school = school mr.language = language generated = Date() mr.generated_at = generated.get_datetime(filepath_split[2]+'-'+filepath_split[3]+'-1') #fil = open(file_path) #django_file = File(fil) #mr.pdf.save(file_path, django_file, save=True) mr.pdf.name = file_path.split('/', 1)[1] mr.save()